使用PosixFileAttributeView维护POSIX文件属性
import java.nio.file.FileSystem;//N o w J a v a . c o m 提供 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; import java.nio.file.attribute.PosixFilePermission; import java.util.Set; public class Main { public static void main(String[] args) throws Exception { Path path = Paths.get("home/docs/users.txt"); PosixFileAttributeView view = Files.getFileAttributeView(path, PosixFileAttributeView.class); PosixFileAttributes attributes = view.readAttributes(); System.out.println("Group: " + attributes.group()); System.out.println("Owner: " + attributes.owner().getName()); /*N o w J a v a . c o m 提 供*/ Set<