用递归方法删除不为空的目录
来源:互联网 发布:倾斜摄影测量软件 编辑:程序博客网 时间:2024/05/18 16:54
If the directory is not empty, it is necessary to first recursivelydelete all files and subdirectories in the directory. Here is amethod that will delete a non-empty directory.
// Deletes all files and subdirectories under dir.
// Returns true if all deletions were successful.
// If a deletion fails, the method stops attempting to delete and returns false.
public static boolean deleteDir(File dir) {
if (dir.isDirectory()) {
String[] children = dir.list();
for (int i=0; i<children.length; i++) {
boolean success = deleteDir(new File(dir, children[i]));
if (!success) {
return false;
}
}
}
// The directory is now empty so delete it
return dir.delete();
}
- 用递归方法删除不为空的目录
- 删除不为空目录的两种实现方式
- 删除不为空目录的两种实现方式
- 递归删除空目录
- PHP用递归的方法删除目录
- 递归删除非空目录
- Ruby递归删除空目录
- python删除非空目录的方法
- 使用递归删除目录下的空文档和文件
- 判断字符串不为空的方法
- java删除目录,必须目录为空
- java实现递归删除非空目录
- 删除U盘文件显示 无法删除:目录不为空 解决办法
- mysql查找字段空、不为空的方法总结
- postgresql查找字段空、不为空的方法总结
- .net对不为空的文件夹进行删除
- Oracle 如何删除不为空的表空间
- Python-迭代删除不为空的文件夹
- 归并排序算法
- jquey简单使用
- 电脑培训中心是“培”训还是“被”训
- 使用gprof分析程序(转贴)
- IP分片和TCP分片的区别
- 用递归方法删除不为空的目录
- 虚拟机上网的设置
- 关于宏,预定义资料的收集(—)
- 有用名言
- MD5
- ArcSDE历史库功能
- C语言函数参数传递问题
- 宏相关学习(二)
- php-gtk-(1)