You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
16 lines
524 B
Java
16 lines
524 B
Java
5 years ago
|
import java.io.File;
|
||
|
|
||
|
public class Main {
|
||
|
public static long getFileSize(String filename) {
|
||
|
File file = new File(filename);
|
||
|
if (!file.exists() || !file.isFile()) {
|
||
|
System.out.println("File doesn\'t exist");
|
||
|
return -1;
|
||
|
}
|
||
|
return file.length();
|
||
|
}
|
||
|
public static void main(String[] args) {
|
||
|
long size = getFileSize("c:/java.txt");
|
||
|
System.out.println("Filesize in bytes: " + size);
|
||
|
}
|
||
|
}
|