Java PosixFileAttributes .permissions ()

Syntax

PosixFileAttributes.permissions() has the following syntax.

Set < PosixFilePermission > permissions()

Example

In the following code shows how to use PosixFileAttributes.permissions() method.


//from   ww w  . j a va2 s.  c  om
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.nio.file.attribute.PosixFileAttributeView;
import java.nio.file.attribute.PosixFileAttributes;

public class Main {

  public static void main(String[] args) throws Exception {

    Path path = Paths.get("c:/home/tutorial/Java/JavaFX/Topic.txt");

    PosixFileAttributes attr = Files.readAttributes(path,PosixFileAttributes.class);
    attr = Files.getFileAttributeView(path, PosixFileAttributeView.class)
        .readAttributes();

    System.out.println("File owner: " + attr.owner().getName());
    System.out.println("File group: " + attr.group().getName());
    System.out.println("File permissions: " + attr.permissions().toString());

  }
}




















Home »
  Java Tutorial »
    java.nio.file.attribute »




BasicFileAttributes
BasicFileAttributeView
DosFileAttributes
FileTime
PosixFileAttributes
PosixFilePermissions