6069

Is it possible to set the POSIX group of a file?

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

Recommend

  • CMFCOutlookBarPane icons disappearing when dragging
  • Active directory : get groups where a user is member
  • How do I set the owner of a message queue?
  • Read user authorization groups from Active Directory
  • Displaying a Bitmap on Canvas in Surfaceview
  • A few /proc and /dev questions
  • Helgrind for Windows?
  • Declare struct containing time_t field in Python CFFI
  • MVC: How do you give a viewmodel a list and correctly output it on .cshtml
  • Issue with std::thread when using g++ in 32-bit MinGW 4.8.0
  • Grails eager fetch doesn't retrieve all data
  • How to extract a number from a string [duplicate]
  • Google Calendar Api is not showing event list
  • How to get a list with description of all dba packages
  • Owin Authentication and claims in asp.net how to access user data
  • OSX - always hide certain files
  • JBoss External Properties Files in Classpath
  • Tamper-proof configuration files in .NET?
  • Connect .sks to skscene.h
  • Why does access(2) check for real and not effective UID?
  • Checking free space on FTP server
  • script to move all files from one location to another location
  • WinForms: two way TextBox problem
  • ILMerge & Keep Assembly Name
  • Symfony2: How to get request parameter
  • Google cloud sdk not working when python points python3
  • Why winpcap requires both .lib and .dll to run?
  • jqPlot EnhancedLegendRenderer plugin does not toggle series for Pie charts
  • Run Powershell script from inside other Powershell script with dynamic redirection to file
  • How do I rollback to a specific git commit
  • Is there a mandatory requirement to switch app.yaml?
  • Load html files in TinyMce
  • How can I get HTML syntax highlighting in my editor for CakePHP?
  • How to set the response of a form post action to a iframe source?
  • coudnt use logback because of log4j
  • how does django model after text[] in postgresql [duplicate]
  • Change div Background jquery
  • Qt: Run a script BEFORE make
  • Busy indicator not showing up in wpf window [duplicate]
  • reshape alternating columns in less time and using less memory