Answers for "java set file folder permissions"

0

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);
}
Posted by: Guest on October-30-2021

Code answers related to "java set file folder permissions"

Code answers related to "Java"

Java Answers by Framework

Browse Popular Code Answers by Language