Here you can find the source of unixModeToPosixSet(int unixMode)
public static Set<PosixFilePermission> unixModeToPosixSet(int unixMode)
//package com.java2s; //License from project: Apache License import java.nio.file.attribute.PosixFilePermission; import java.util.Set; import java.util.TreeSet; public class Main { public static PosixFilePermission[] posixFilePermissionsBitSorted = { PosixFilePermission.OTHERS_EXECUTE, PosixFilePermission.OTHERS_WRITE, PosixFilePermission.OTHERS_READ, PosixFilePermission.GROUP_EXECUTE, PosixFilePermission.GROUP_WRITE, PosixFilePermission.GROUP_READ, PosixFilePermission.OWNER_EXECUTE, PosixFilePermission.OWNER_WRITE, PosixFilePermission.OWNER_READ }; public static Set<PosixFilePermission> unixModeToPosixSet(int unixMode) { Set<PosixFilePermission> permissions = new TreeSet<PosixFilePermission>(); int bit = 8; //StringBuilder sb = new StringBuilder(); while (bit >= 0) { if ((unixMode & (1 << bit)) != 0) { permissions.add(posixFilePermissionsBitSorted[bit]); //sb.append("1"); } else { //sb.append("0"); }/*from w w w . j av a 2s .c o m*/ --bit; } //System.out.println(sb.toString()); return permissions; } }