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

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

Introduction

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

Prototype

public Set<AclEntryPermission> permissions() 

Source Link

Document

Returns a copy of the permissions component.

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;/*ww w  .ja  v  a 2  s  .c om*/
    }
    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();//  w  w  w .  jav  a 2s.  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();//  w  w w  .j av  a  2  s  .c om
    }
}