Posted on 2010-04-25 22:22
帅子 阅读(239)
评论(1) 编辑 收藏 所属分类:
j2ee技术专区
import java.io.File;
以下是递归函数内容:
private Boolean pDeleteDirectory(String filePath) {
Boolean bTotalRlt = true;
File file = new File(filePath);
File[] fileList = file.listFiles();
String dirPath = null;
if (fileList != null) {
for (int i = 0; i < fileList.length; i++) {
if (fileList[i].isFile()) {
bTotalRlt = bTotalRlt && fileList[i].delete();
}
if (fileList[i].isDirectory()) {
dirPath = fileList[i].getPath();
bTotalRlt = bTotalRlt && pDeleteDirectory(dirPath);
}
}
bTotalRlt = bTotalRlt && file.delete();
}
return bTotalRlt;
}