Example usage for java.nio.file SecureDirectoryStream getFileAttributeView

List of usage examples for java.nio.file SecureDirectoryStream getFileAttributeView

Introduction

In this page you can find the example usage for java.nio.file SecureDirectoryStream getFileAttributeView.

Prototype

<V extends FileAttributeView> V getFileAttributeView(Class<V> type);

Source Link

Document

Returns a new file attribute view to access the file attributes of this directory.

Usage

From source file:Test.java

public static void main(String args[]) throws IOException {
    Path path = Paths.get("home/docs");
    SecureDirectoryStream<Path> sds = (SecureDirectoryStream) Files.newDirectoryStream(path);
    PosixFileAttributeView view = sds.getFileAttributeView(PosixFileAttributeView.class);
    PosixFileAttributes attributes = view.readAttributes();
    Set<PosixFilePermission> permissions = attributes.permissions();

    for (PosixFilePermission permission : permissions) {
        System.out.print(permission.toString() + ' ');
    }/*  w  ww  . j a  v a  2 s .c o  m*/
}