JAVA中怎么用程序把记事本的属性改为只读
2013-08-10
展开全部
File file = new File("test.txt");
try {
file.createNewFile();
file.setReadOnly();
if (file.canWrite()) {
System.out.println("writable!");
} else {
System.out.println("read only!");
}
} catch (IOException e) {
e.printStackTrace();
}
try {
file.createNewFile();
file.setReadOnly();
if (file.canWrite()) {
System.out.println("writable!");
} else {
System.out.println("read only!");
}
} catch (IOException e) {
e.printStackTrace();
}
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询