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();

猜你喜欢

转载自blog.csdn.net/weixin_42350212/article/details/80871247
今日推荐