Set<PosixFilePermission> (int mode) { Set<PosixFilePermission> permissions = EnumSet.noneOf(PosixFilePermission.class); if ((mode & S_IRUSR) != 0) permissions.add(PosixFilePermission.OWNER_READ); if ((mode & S_IWUSR) != 0) permissions.add(PosixFilePermission.OWNER_WRITE); if ((mode & S_IXUSR) != 0) permissions.add(PosixFilePermission.OWNER_EXECUTE); if ((mode & S_IRGRP) != 0) permissions.add(PosixFilePermission.GROUP_READ); if ((mode & S_IWGRP) != 0) permissions.add(PosixFilePermission.GROUP_WRITE); if ((mode & S_IXGRP) != 0) permissions.add(PosixFilePermission.GROUP_EXECUTE); if ((mode & S_IROTH) != 0) permissions.add(PosixFilePermission.OTHERS_READ); if ((mode & S_IWOTH) != 0) permissions.add(PosixFilePermission.OTHERS_WRITE); if ((mode & S_IXOTH) != 0) permissions.add(PosixFilePermission.OTHERS_EXECUTE); return permissions; }