集册 Java实例教程 遍历列表并提取每个Read ACL条目的组件

遍历列表并提取每个Read ACL条目的组件

欢马劈雪     最近更新时间:2020-01-02 10:19:05

364
遍历列表并提取每个Read ACL条目的组件

import java.io.IOException;

import java.nio.file.Files;

import java.nio.file.LinkOption;
/*
n o w j a v a . c o m - 时  代  Java 提 供
*/

import java.nio.file.Path;

import java.nio.file.Paths;

import java.nio.file.attribute.AclEntry;

import java.util.List;


public class Main {

  public static void main(String[] args) {


    List<AclEntry> acllist = null;

    Path path = Paths.get("C:/folder1/folder2/folder4", "test.txt");


    try {// 来 自 时 代 J a v a 公 众 号 - N o w J a v  a . c o m

      acllist = (List<AclEntry>) Files.getAttribute(path, "acl:acl",

          LinkOption.NOFOLLOW_LINKS);

    } catch (IOException e) {

      System.err.println(e);

    }


    for (AclEntry aclentry : acllist) {

      System.out.println("Principal: " + aclentry.principal().getName());

      System.out.println(
展开阅读全文