Java Files get file size
import java.io.IOException; import java.nio.file.Files; import java.nio.file.Path; import java.nio.file.Paths; public class Main { public static void main(String[] args) throws IOException { Path path = Paths.get("Main.java"); long b = Files.size(path); System.out.println(b);// w w w . jav a2s. c om } }