Java Java File.length()
方法具有以下語法。
public long length()
在下面的程式碼顯示如何使用File.length()
方法。
import java.io.File;
public class Main {
public static void main(String[] args) {
File f = new File("c:/test.txt");
boolean bool = f.exists();
if (bool) {
long len = f.length();//::W WW.y I I b a i.c o m
String path = f.getPath();
System.out.print(path + " file length: " + len);
}
}
}