<span style="font-size:18px;">package com.io;
//通过代码将一个文件设置成隐藏成隐藏的属性
import java.io.File;
import java.io.IOException;
public class IoTest {
public static void main(String[] args) {
File file = new File("D:" + File.separator + "w.txt");
try {
file.createNewFile();
// R : 只读文件属性。A:存档文件属性。S:系统文件属性。H:隐藏文件属性。
String sets = "attrib +H \"" + file.getAbsolutePath() + "\"";
System.out.println(sets);
// 运行命令
Runtime.getRuntime().exec(sets);
} catch (IOException e) {
e.printStackTrace();
}
}
}
</span>
java设置隐藏文件或者文件夹
最新推荐文章于 2023-04-28 16:34:57 发布