java代码 创建文件夹的方法

1、

1
2
3
4
5
String strPath = "E:\\a\\aa\\aaa.txt";
File file = new File(strPath);
if(!file.exists())){
 file.file.mkdirs();
}

2、

1
2
3
4
5
6
7
String strPath = "E:\\a\\aa\\aaa.txt";
File file = new File(strPath);
File fileParent = file.getParentFile();
if(!fileParent.exists()){
 fileParent.mkdirs();
}
file.createNewFile();
posted @ 2018-06-30 23:59  Linux黑客小课堂  阅读(140)  评论(0)    收藏  举报