Read an ACL Using Files.getFileAttributeView() - Java File Path IO

Java examples for File Path IO:ACL File

Description

Read an ACL Using Files.getFileAttributeView()

Demo Code

import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.nio.file.attribute.AclEntry;
import java.nio.file.attribute.AclFileAttributeView;
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");

    AclFileAttributeView aclview = Files.getFileAttributeView(path,
        AclFileAttributeView.class);
    try {/*  w w w .j  av a  2  s . c o  m*/
      acllist = aclview.getAcl();
    } catch (IOException e) {
      System.err.println(e);
    }

  }
}

Result


Related Tutorials