使用Files.getAttribute()获取文件所有者
import java.io.IOException; import java.nio.file.Files; import java.nio.file.LinkOption;/*nowjava - 时代Java 提 供*/ import java.nio.file.Path; import java.nio.file.Paths; import java.nio.file.attribute.UserPrincipal; public class Main { public static void main(String[] args) { Path path = Paths.get("C:/folder1/folder2/folder4", "test.txt"); try { UserPrincipal owner = (UserPrincipal) Files.getAttribute(path, "owner:owner",LinkOption.NOFOLLOW_LINKS); /** 来自 n o w j a v a