Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

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.AclEntryPermission;
import java.nio.file.attribute.AclFileAttributeView;
import java.util.List;
import java.util.Set;

public class Main {
    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;
        }
        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);
            }

        }

    }
}