Java Files create directory with permission
import java.io.IOException; import java.nio.file.FileSystem; import java.nio.file.FileSystems; import java.nio.file.Files; import java.nio.file.Path; import java.nio.file.attribute.FileAttribute; import java.nio.file.attribute.PosixFilePermission; import java.nio.file.attribute.PosixFilePermissions; import java.util.Set; public class Main { public static void main(String[] args) { FileSystem fileSystem = FileSystems.getDefault(); Path directory = fileSystem.getPath("./newDirectoryWPermissions"); try {/*w w w .j av a 2 s . c om*/ Set<PosixFilePermission> perms = PosixFilePermissions.fromString("rwxr-x---"); FileAttribute<Set<PosixFilePermission>> attr = PosixFilePermissions.asFileAttribute(perms); Files.createDirectory(directory, attr); } catch (IOException e) { e.printStackTrace(); } } }