Example usage for java.nio.file.attribute AclEntry type

List of usage examples for java.nio.file.attribute AclEntry type

Introduction

In this page you can find the example usage for java.nio.file.attribute AclEntry type.

Prototype

AclEntryType type

To view the source code for java.nio.file.attribute AclEntry type.

Click Source Link

Usage

From source file:Main.java

public static void main(String[] args) throws Exception {
    Path path = Paths.get("C:\\Java_Dev\\test1.txt");
    AclFileAttributeView aclView = Files.getFileAttributeView(path, AclFileAttributeView.class);
    if (aclView == null) {
        System.out.format("ACL view  is not  supported.%n");
        return;/*from  w  ww. j a v a2 s .  co  m*/
    }
    List<AclEntry> aclEntries = aclView.getAcl();
    for (AclEntry entry : aclEntries) {
        System.out.format("Principal: %s%n", entry.principal());
        System.out.format("Type: %s%n", entry.type());
        System.out.format("Permissions are:%n");

        Set<AclEntryPermission> permissions = entry.permissions();
        for (AclEntryPermission p : permissions) {
            System.out.format("%s %n", p);
        }

    }

}

From source file:Test.java

public static void main(String[] args) throws Exception {
    Path path = Paths.get("C:/home/docs/users.txt");
    AclFileAttributeView view = Files.getFileAttributeView(path, AclFileAttributeView.class);
    List<AclEntry> aclEntryList = view.getAcl();
    for (AclEntry entry : aclEntryList) {
        System.out.println("User Principal Name: " + entry.principal().getName());
        System.out.println("ACL Entry Type: " + entry.type());
        displayEntryFlags(entry.flags());
        displayPermissions(entry.permissions());
        System.out.println();//from w  ww .  j a  v  a2  s .  com
    }
}

From source file:Test.java

private static void displayAclEntries(List<AclEntry> aclEntryList) {
    System.out.println("ACL Entry List size: " + aclEntryList.size());
    for (AclEntry entry : aclEntryList) {
        System.out.println("User Principal Name: " + entry.principal().getName());
        System.out.println("ACL Entry Type: " + entry.type());
        displayEntryFlags(entry.flags());
        displayPermissions(entry.permissions());
        System.out.println();/*  ww  w.  ja v  a  2s  .c  o m*/
    }
}