文件权限属性设置:
package myfile.tools;
import java.io.File;
import java.io.IOException;
public class FileAttrib {
public static void main(String[] args) throws IOException{
File file=new File("c:/test/test.txt");
String atts="attrib +a +s +h +r "+file.getAbsolutePath();
String caclss="cacls "+file.getAbsolutePath()+" /e /p everyone:f";
// Runtime.getRuntime().exec(atts);
Runtime.getRuntime().exec(caclss);
System.out.println(atts);
}
}
本文介绍了一个使用Java进行文件权限设置的例子。通过Runtime类执行系统命令,实现对指定文件添加只读、系统、隐藏等属性,并调整文件访问权限,允许everyone全权访问。
1138

被折叠的 条评论
为什么被折叠?



