调用Files.getFileAttributeView()方法以提取POSIX属性
import java.io.IOException;/*from nowjava.com*/ import java.nio.file.Files; import java.nio.file.Path; import java.nio.file.Paths; import java.nio.file.attribute.PosixFileAttributeView; import java.nio.file.attribute.PosixFileAttributes; public class Main { public static void main(String[] args) { PosixFileAttributes attr = null; Path path = Paths.get("/home/folder1/folder2/folder3/test.txt"); try { /* 时 代 J a v a - nowjava.com */ attr = Files.getFileAttributeView(path, PosixFileAttributeView.class) .readAttributes(); } catch (IOException e) { System.err.println(e); } System.out.println("File owner: " + attr.owner().getNa