最近想写一些算法有关的东西了,拒绝简单重复的 CURD ,让自己的脑子动起来。
public class RecursionDelete {
public static void main(String[] args) {
File f = new File("/Users/liwei/codes/SpringBootSecurityJSP");
recursionDelete(f);
}
private static void recursionDelete(File f) {
if (f.isDirectory()) {
for (File file : f.listFiles()) {
recursionDelete(file);
}
boolean deleteFolder = f.delete();
System.out.println("删除了文件夹 => " + f.getAbsolutePath() + " " + deleteFolder);
} else {
boolean delete = f.delete();
System.out.println(f.getAbsolutePath() + f.getName() + " " + delete);
}
}
}