Java PosixFileAttributes get posix file permission
import java.io.IOException; 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; import java.nio.file.attribute.PosixFilePermission; import java.util.Set; public class Main { public static void main(String[] args) { Path path = Paths.get("home/docs/users.txt"); try {//w w w .j a va 2s . c o m PosixFileAttributeView view = Files.getFileAttributeView(path, PosixFileAttributeView.class); PosixFileAttributes attributes = view.readAttributes(); Set<PosixFilePermission> permissions = attributes.permissions(); for (PosixFilePermission permission : permissions) { System.out.print(permission.toString() + ' '); } } catch (IOException ex) { } } }