How to use the java7 file attribute APIs to get the digital groupid / userid?

I can use the following code to get the name of the file owner;

final PosixFileAttributes basicFileAttributes =
        Files.readAttributes( path,PosixFileAttributes.class,LinkOption.nofollow_LINKS );
    String ownerName = basicFileAttributes.owner().getName();

But I also try to catch the number UNIX ID of the user in question. In the debugger, I can see that it is hidden in "unixfileattributes" (subclass of posixfileattributes), but is there any reasonable standard way to catch it?

Solution

In fact, there is a "UNIX" view, and you can access such UNIX specific properties in the following ways:

int uid = (int) Files.getAttribute(path,"unix:uid",nofollow_LINKS);
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
分享
二维码
< <上一篇
下一篇>>