出力:
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.