java - setReadable(true) doesn't work after setReadable(false) -


i testing method have written throwing file exception. triggering exception setting read permissions on file false

     file f = new file(unreadablefile);      f.setreadable(false);      // run test      f.setreadable(true); 

the problem f.setreadable(true) not setting permissions should be. have test tests normal mode of operations, , fails because f.setreadable(true) didn't restore file before exception test run. have checked permissions on disk, , wrong.

quoting docs

returns true if , if operation succeeded. operation fail if user not have permission change access permissions of abstract pathname. if readable false , underlying file system not implement read permission, operation fail.

check return value , check if have permissions operation. operation delete() , can fail if not have permissions.


Comments

Popular posts from this blog

monitor web browser programmatically in Android? -

Shrink a YouTube video to responsive width -

wpf - PdfWriter.GetInstance throws System.NullReferenceException -