6069

Question:
I am aware that it's possible to set the owner of a file using <a href="https://docs.oracle.com/javase/7/docs/api/java/nio/file/Files.html#setOwner%28java.nio.file.Path,%20java.nio.file.attribute.UserPrincipal%29" rel="nofollow">Files.setOwner
</a>:
Files.setOwner(Path path, UserPrincipal owner);
However what about the POSIX <em>group</em>? There is no such Files.setGroup()
method in the API, and not even using the FileOwnerAttributeView
works, as there is only setOwner
too.
Is it possible at all?
Answer1:If your app is working on POSIX
systems exclusively, there's <a href="http://docs.oracle.com/javase/7/docs/api/java/nio/file/attribute/PosixFileAttributeView.html#setGroup%28java.nio.file.attribute.GroupPrincipal%29" rel="nofollow">PosixFileAttributeView.setGroup()</a>.