Access to files in Java has implemented very good.

First of all, we should to create a file and look what we can do with it.
The next step we will remove all permissions and check it out.

[cc lang=”java”]
//Create file
File myFile = new File(“mynewfile”);
myFile.createNewFile();
//Check permissions
System.out.println(myFile.canExecute());
System.out.println(myFile.canWrite());
System.out.println(myFile.canRead());
//Change permissions
myFile.setExecutable(false);
myFile.setReadable(false);
myFile.setWritable(false);
//Check permissions again
System.out.println(myFile.canExecute());
System.out.println(myFile.canWrite());
System.out.println(myFile.canRead());
[/cc]