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

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

Introduction

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

Prototype

public UserPrincipal principal() 

Source Link

Document

Returns the principal 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;/*from  w ww .ja v  a  2s .  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();/*from w  ww .  j av a 2s  .c  o  m*/
    }
}

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