public static void main(String[] args) {
String path = "E:\\SpecializedCode";
//方法一
/*File file1 = new File(path, "./javase/day1/笔记");
File file2 = new File(path, "./javase/day1/视频");
File file3 = new File(path, "./javase/day1/作业");
File file11 = new File(path, "./javase/day2/笔记");
File file22 = new File(path, "./javase/day2/视频");
File file33 = new File(path, "./javase/day2/作业");
file1.mkdirs();
file2.mkdirs();
file3.mkdirs();
file11.mkdirs();
file22.mkdirs();
file33.mkdirs();
File fi1 = new File(file1, "./笔记.txt");
File fi2 = new File(file2, "./视频.mp4");
File fi3 = new File(file3, "./作业.txt");
File fi4 = new File(file11, "./笔记.txt");
File fi5 = new File(file22, "./笔记.txt");
File fi6 = new File(file33, "./笔记.txt");
try {
fi1.createNewFile();
fi2.createNewFile();
fi3.createNewFile();
fi4.createNewFile();
fi5.createNewFile();
fi6.createNewFile();
} catch (IOException e) {
e.printStackTrace();
}*/
//方法二
/*for (int i=1;i<=2;i++){
File dayFile = new File(path,"./javase/day"+i);
dayFile.mkdirs();
File note= new File(dayFile,"./笔记");
File shiping= new File(dayFile,"./视频");
File zuoye= new File(dayFile,"./作业");
note.mkdirs();
shiping.mkdirs();
zuoye.mkdirs();
try {
new File(note,"./笔记.txt").createNewFile();
new File(shiping,"./视频.mp4").createNewFile();
new File(zuoye,"./作业.txt").createNewFile();
}catch (Exception e){
e.printStackTrace();
}*/
//删除文件,目录---delete()-删除的目录里面没有文件才能删除
System.out.println(new File("E:\\SpecializedCode\\javase\\day1\\作业").delete());//第一次运行返回false,第二次运行返回ture
System.out.println(new File("E:\\SpecializedCode\\javase\\day1\\作业\\作业.txt").delete());//返回ture,第二次运行返回false
}
04-15
3958
![](https://csdnimg.cn/release/blogv2/dist/pc/img/readCountWhite.png)
03-07
308
![](https://csdnimg.cn/release/blogv2/dist/pc/img/readCountWhite.png)