I have a file from which I have suppressed every permission. No one should be able to read the file, right? In fact, if I run
File f = new File("not_readable.pdf");
System.out.println(f.canRead())
I get
false
However, if I call
File f = new File("not_readable.pdf");
System.out.println(f.length())
I get
455074
It is my understanding that in order to get the size of a file one must open and read the file first, but this result strongly suggests that I'm wrong. Does anyone know why this happens? Also, is there a way to prevent Java's file.length() method from accessing the size of a file?
I am using Ubuntu 12.10