Stop giving up immediately on the first failed file deletion and continue deleting files recursively.

This commit is contained in:
Jeremy Wood 2012-04-06 14:54:48 -04:00
parent 2e4b814d6d
commit da54f9769b
1 changed files with 3 additions and 6 deletions

View File

@ -25,19 +25,16 @@ public class FileUtils {
*/
public static boolean deleteFolder(File file) {
if (file.exists()) {
boolean ret = true;
// If the file exists, and it has more than one file in it.
if (file.isDirectory()) {
for (File f : file.listFiles()) {
if (!FileUtils.deleteFolder(f)) {
return false;
}
ret = ret && deleteFolder(f);
}
}
file.delete();
return !file.exists();
return ret && file.delete();
} else {
return false;
}
}
}