import java.io.File;
public class Main {
public static void main(String[] args) {
File file = new File(args[0]);
System.out.println("exec:" + file.canExecute());
System.out.println("read:" + file.canRead());
System.out.println("write:" + file.canWrite());
System.out.println(file.setLastModified(System.currentTimeMillis()));
}
}
Компилируем в ~. В ~ создаем файл aaa.txt, делаем
~ $ sudo chown root:root aaa.txt
~ $ sudo chmod 777 aaa.txt
~ $ ls -la aaa.txt
-rwxrwxrwx 1 root root 472 2009-11-24 12:09 aaa.txt
~ $ java -Djava.security.debug=all Main /home/jfreem/aaa.txt
scl: getPermissions ProtectionDomain (file:/home/jfreem/ <no signer certificates>)
sun.misc.Launcher$AppClassLoader@1c78e57
<no principals>
java.security.Permissions@1186fab (
(java.lang.RuntimePermission exitVM)
(java.io.FilePermission /home/jfreem/- read)
)
scl:
exec:true
read:true
write:true
false
Что самое непонятное -
~ $ touch aaa.txt
~ $ touch -m aaa.txt
touch: setting times of `aaa.txt': Operation not permitted