How do I get the name of the java file owner on OSX?

I just need to know the owner name of the file using java on the MAC – how can I get it? thank you!

Solution

This is annoying There is no standard way to get the file owner (at least Java 6, which is the current production version of OSX) Now the simplest way is to use processbuilder to execute the call to stat, take the file name as the parameter, and then parse the results to be returned on the standard output channel of the child process You must be careful when parsing the results, because the user name on OSX may contain spaces

Alternatively, use JNI

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>