代码:
import java.io.File;
public class Test03 {
public static void main(String[] args) {
//删除多级空目录
File file = new File("d:\\aa");
removeDirectory(file);
}
//递归删除多级空目录
public static void removeDirectory(File file) {
File[] fileList = file.listFiles();
for (File f : fileList) {//遍历集合
if (f.isDirectory()) {//判断是目录
removeDirectory(f);//递归调用
f.delete();//删除该目录
}
}
}
}
标签:Java,file,递归,removeDirectory,空目录,File,删除,public
来源: https://blog.csdn.net/xilin6664/article/details/89040075