Possible Duplicate:
How do I get the name of a file’s owner in Java on OSX?
Is there any method on a class from java.io, java.nio, commons-io, etc. that I can use to get the owner of a given file in my filesystem?
I really don’t want to create a shell to execute an unix-only/windows-only command to get it. It would look awful and wouldn’t be platform independent.
Judging from the Javadoc, you should be able to do this:
(where
fileis an instance ofjava.io.File). Note that this requires Java 7. Also note that it will throw anUnsupportedOperationExceptionon some platforms, because some file-systems, such as FAT32, have no concept of a file “owner”.