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(),做准备

 
posted @ 2017-12-18 18:09  陽66  阅读(350)  评论(0)    收藏  举报