Creating File using Java on Mac

JDK 7 has support for setting File attributes when create a file, So i was testing that out. When i tried to create a file and set security attributes like this

 Set perms = PosixFilePermissions.fromString("rwxrwxrw");
I got the following exception

Exception in thread "main" java.lang.IllegalArgumentException: Invalid mode
 at java.nio.file.attribute.PosixFilePermissions.fromString(PosixFilePermissions.java:128)
 at com.test.HelloPaths.readWriteFiles(HelloPaths.java:55)
 at com.test.HelloPaths.main(HelloPaths.java:23)
It seems that in case of Mac you have to use code like this for file attribute association to work

No comments: