创建一级目录,多级目录

来源:互联网 发布:mmd极乐净土数据 编辑:程序博客网 时间:2024/05/22 12:48

一级目录:

 File file = new File("c://aa");

file.mkdir();

多级目录:

1.

File file = new File("c:/aaa/bbb/ccc");
 file.mkdirs();

 

 

2.

public void makedir(){

String path="c:/aaa/bbb/ccc";  

  StringTokenizer st = new StringTokenizer(path, "/");
  String path1 = st.nextToken() + "/";
  String path2 = path1;
  while (st.hasMoreTokens()) {
   path1 = st.nextToken() + "/";
   path2 += path1;
   File inbox = new File(path2);
   if (!inbox.exists())
    inbox.mkdir();  
        }
 }

原创粉丝点击