Date: 2020sep6
Language: Java
Q. Java: make a file world readable (chmod 666)
A. Like this:
File myfile = new File("/home/myfile.txt");
myfile.setExecutable(boolean);
myfile.setReadable(boolean);
myfile.setWritable(boolean);
Also:
myfile.setExecutable(boolean executable, boolean ownerOnly);
myfile.setReadOnly(boolean);
And for checking:
myfile.canExecute();
myfile.canRead();
myfile.canWrite();
This works on any JVM.
It also works on Android when you have permission (a different kind of permission).
If you want to set permission by owner, user, group use
PosixFileAttributeView.setPermissions()