O'Reilly logo

Beginning Java 8 Language Features: Lambda Expressions, Inner Classes, Th reads, I/O, Collections,and Streams by Kishori Sharan

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

// 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 ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required