即使通过Java设置了“读取”权限,也无法读取Windows文件

时间:2019-10-21 05:59:45

标签: java windows permissions java.nio.file

我正在尝试从Windows中的java向Administrators组设置文件权限。 下面是我的代码:

rw-------

}

public static void main(String[] args) throws IOException   {

 final Path path = Paths.get("C:/Dev/dummy/test"); 
 FileAttribute<?> permissions = new FileAttribute<List<AclEntry>>() {
    public String name() {
        return "acl:acl";
    }
    public List<AclEntry> value() {
        try {
            return get600ACL(path.getFileSystem());
        } catch (IOException e) {
            e.printStackTrace();
        }
        return null;
    }
 };

  Files.createFile(path, permissions);

After creating file, the permissions are proper as seen in this image

但是,当我创建一个新用户时,请给他授予管理员权限并尝试打开该文件,这表明该用户没有读取权限。 有人可以告诉我我在哪里错吗?

0 个答案:

没有答案