输出:
import java.io.File;
import java.io.IOException;
public class ExampleFilePermission
{
public static void main( String[] args )
{
File file = new File(test.txt”);
if(file.exists()){
System.out.println(允许执行:” + file.canExecute());
System.out.println(允许写入:” + file.canWrite());
System.out.println(允许读取:” + file.canRead());
}
file.setExecutable(false);
file.setReadable(false);
file.setWritable(false);
System.out.println(允许执行: ” + file.canExecute());
System.out.println(允许写入:” + file.canWrite());
System.out.println(允许读取:” + file.canRead());
}
}
允许执行: true
允许写入: true
允许读取: true
允许执行: false
允许写入: false
允许读取: false
Please disable your ad blocker and refresh the window to use this website.