File类的文件属性问题
/** * 创建的文件的属性 */ @Test public void testFile(){ /** *权限有以下几种: R : 只读文件属性。A:存档文件属性。S:系统文件属性。H:隐藏文件属性。 } */ File file=new File("D:/huhy");//定义文件路径 try { if(!file.exists()) { file.mkdir();//如果文件路径不存在就创建一个 String string=" attrib +R "+file.getAbsolutePath(); //设置文件属性为只读 Runtime.getRuntime().exec(string); // } } catch (IOException e) { e.printStackTrace(); } }
这是在位Runtime的exec(),做准备
本文来自博客园,作者:huhy,转载请注明原文链接:https://www.cnblogs.com/huhongy/p/8058958.html

浙公网安备 33010602011771号