创建多层目录

//c:/aaa/bbb/ccc

//生成多层目录
public static void mkdir(String path) { File file = null; try { file= new File(path); if (!file.exists()) { file.mkdirs(); } } catch (Exception e) { e.printStackTrace(); } finally { file= null; } }
//===========>生成三个目录
public static void mkdir(String path) {
        File file
= null;
       
try {
              file
= new File(path);
           
   file.getParentFile().mkdirs();
         file.createNewFile(); 
          }
catch (Exception e) {
            e.printStackTrace();
         }
finally {
            file
= null;
        }
    }
//============>生成两个目录一个ccc.txt文件

 

posted on 2013-05-14 09:43  过-路-人  阅读(166)  评论(0)    收藏  举报

导航