管理POSIX属性
/**来自 时 代 J a v a**/ import java.nio.file.FileSystem; 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(); Set<PosixFilePermission> permissions = attributes.permissions(); listPermissions(permissions);//n o w j a v a . c o m 提供 permissions.add(PosixFilePermission.OTHERS_WRITE); view.setPermissions(permissions); System.out.println(); listPermissions(permissions); } private static void listPermissions(Set<PosixFilePermission> permissions)