java递归删除文件夹
2015-10-30 14:59
519 查看
调用方法
public static void main(String[] args) {
new FileDeleteTest().clearFiles("D:/temp");
}
//删除文件和目录
private void clearFiles(String workspaceRootPath){
File file = new File(workspaceRootPath);
if(file.exists()){
deleteFile(file);
}
else {
// do something
}
}
private void deleteFile(File file){
if(file.isDirectory()){
File[] files = file.listFiles();
for(int i=0; i<files.length; i++){
deleteFile(files[i]);
}
}
file.delete();
}
来自,
http://www.cnblogs.com/yangzhilong/archive/2013/01/28/2880072.html
原作者 yangzhilong
public static void main(String[] args) {
new FileDeleteTest().clearFiles("D:/temp");
}
//删除文件和目录
private void clearFiles(String workspaceRootPath){
File file = new File(workspaceRootPath);
if(file.exists()){
deleteFile(file);
}
else {
// do something
}
}
private void deleteFile(File file){
if(file.isDirectory()){
File[] files = file.listFiles();
for(int i=0; i<files.length; i++){
deleteFile(files[i]);
}
}
file.delete();
}
来自,
http://www.cnblogs.com/yangzhilong/archive/2013/01/28/2880072.html
原作者 yangzhilong
相关文章推荐
- 从”JAVA“而终 1:认识java
- Java 内存——Java虚拟机中对象的创建、存储、访问定位。
- Protobuf基于java的官方示例演示
- Eclipse doesn't remember source lookup path,走断点时显示source not found
- 关于 Fatal error: ‘SpringBoard/SpringBoard.h’ file not found
- struts2 多文件下载
- eclipse关联git的方法
- springMVC返回的json日期为Long的格式化
- C# 高德JavaScrpt地图航迹-实时更新
- spring注解( @Autowired、@Qualifier、@Resource、@PostConstruct、@PreDestroy、 @Component、@Scope)-描述的比较清楚
- java泛型类
- java事件处理机制(自定义事件)
- Android 如何在Eclipse中查看Android API源码以及support包源码
- struts2的单文件下载
- java web开发--Servlet学习之HelloWorld 从部署到开发全过程
- JPA学习笔记-Spring整合JPA
- java script全选反选的实现
- NetworkDispatcher.run: Unhandled exception java.lang.NullPointerException
- java web上传文件保存的目录
- java连接mysql封装类