NIO2: Generic method to set file readonly ?
I am looking for a standard and portable way to set file readonly using the Path API.
Using the XxxAttributes classes, I can access to the details of the FileSystem, but the portable attributes of BasicFileAttributeView are rather limited. There is no equivalent for the File.setReadOnly() method.
I have two solutions:
- Using the old File API:
- Writing a complex method that try to:
- use the DOSFileAttributeView (available only on Windows)
- use the PosixFileAttributeView (not available on Windows)
- and ultimately the ACLFileAttributeView (not available on Linux (maybe because I am missing the acl package)).
Where is the "Write Once, Run Anywhere"?
Montigny le Bretonneux