File attribute settings
package com.file; import java.io.File; /** * Created by elijahliu on 2017/2/11. */ public class SetFileProperty { public static void main(String[] args){ File file = new File("test.file"); if (file.exists()){ file.setWritable(true);//可写 file.setReadable(true);//可读 file.setReadOnly();//只读 } } }
The above is the detailed content of How to set file attributes in java. For more information, please follow other related articles on the PHP Chinese website!