您可以使用File类访问纯文本。
import java.io.File;
public class ReadFile {
public static void main(String[] args) {
File f = null;
String str = "data.txt";
try {
f = new File(str);
boolean bool = f.canExecute();
String a = f.getAbsolutePath();
System.out.print(a);
System.out.println(" is executable: "+ bool);
} catch (Exception e) {
e.printStackTrace();
}
}
}输出结果
C:\Users\data is executable: true