使用Files类的setAttribute方法
import java.io.IOException; import java.nio.file.Files; import java.nio.file.Path; import java.nio.file.Paths;/*来 自 时代Java - nowjava.com*/ import java.nio.file.attribute.PosixFilePermission; public class Main { public static void main(String[] args) throws Exception { Path path = Paths.get("home/docs/users.txt"); try { Files.setAttribute(path, "posix:permission", PosixFilePermission.OT