Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVA

java set file folder permissions

//if you need rw-rw-r  permissions 
public void setPermission(File file) throws IOException{
    Set<PosixFilePermission> perms = new HashSet<>();
    perms.add(PosixFilePermission.OWNER_READ);
    perms.add(PosixFilePermission.OWNER_WRITE);

    perms.add(PosixFilePermission.OTHERS_READ);
    perms.add(PosixFilePermission.OTHERS_WRITE);

    perms.add(PosixFilePermission.GROUP_READ);

    Files.setPosixFilePermissions(file.toPath(), perms);
}
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #java #set #file #folder #permissions
ADD COMMENT
Topic
Name
5+2 =