Java File.canRead()
方法具有以下语法。
public boolean canRead()
示例
在下面的代码显示如何使用File.canRead()
方法。
import java.io.File;
public class Main {
public static void main(String[] args) {
File f = new File("c:/test.txt");
// returns true if the file can be read
boolean bool = f.canRead();// @ w Ww . y iI b AI.c O M
System.out.print("File can be read: " + bool);
}
}
上面代码执行结果如下 -
File can be read: false