使用Files类的设置/获取POSIX文件权限方法
import java.io.IOException; import java.nio.file.Files;/*from 时代Java公众号*/ import java.nio.file.Path; import java.nio.file.Paths; 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"); try { Set<PosixFilePermission> permissions = Files .getPosixFilePermissions(path); /** * 时 代 J a v a - N o w J a v a . c o m 提 供 **/ System.out.print("Permissions: "); for (PosixFilePermission permission : permissions) { System.o