问题
I am aware that it's possible to set the owner of a file using Files.setOwner:
Files.setOwner(Path path, UserPrincipal owner);
However what about the POSIX group? 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?
回答1:
If your app is working on POSIX
systems exclusively, there's PosixFileAttributeView.setGroup().
来源:https://stackoverflow.com/questions/18686099/is-it-possible-to-set-the-posix-group-of-a-file