August 2014
Intermediate to advanced
704 pages
20h 16m
English
// Get the permission in a string formString rwxFormPermissions = "rw-r-----";// Convert the permission in the string form to a Set of PosixFilePermissionSet<PosixFilePermission> permissions = PosixFilePermissions.fromString(rwxFormPermissions);// Update the permissionsposixView.setPermissions(permissions);
Alternatively, you can also create a Set of PosixFilePermission enum constants directly and set it as the file permissions, like so:
Set<PosixFilePermission> permissions = EnumSet.of(OWNER_READ, OWNER_WRITE, GROUP_READ);posixView.setPermissions(permissions);
Listing 10-19 demonstrates how to read and update POSIX file permissions for a file named luci on UNIX-like platforms. If the file does not exist, the program outputs the stack trace ...