How do I programmatically change file permissions?

前端 未结 12 1041
深忆病人
深忆病人 2020-11-22 04:55

In Java, I\'m dynamically creating a set of files and I\'d like to change the file permissions on these files on a linux/unix file system. I\'d like to be able to execute t

12条回答
  •  粉色の甜心
    2020-11-22 05:45

    simple java code  for change file permission in java  
    
       String path="D:\\file\\read.txt";
            File file=new File(path);
            if (file.exists()) {
                System.out.println("read="+file.canRead());
                System.out.println("write="+file.canWrite());
                System.out.println("Execute="+file.canExecute());
                file.setReadOnly();
            }     
    

    Reference : how to change file permission in java

提交回复
热议问题