/**
* Recurse through directories if present, deleting all contents first so that the directory itself can be deleted.
*
* @param file
* @return
*/
private boolean delete(final File file) {
boolean deleted = true;
if (file.isDirectory()) {
for (final File f : file.listFiles()) {
if (f.isDirectory()) {
deleted &= delete(f);
if (!deleted) {
LOGGER.error("Coulnd't delete " + f);
return deleted;
}
} else {
deleted &= f.delete();
if (!deleted) {
LOGGER.error("Coulnd't delete " + f);
return deleted;
}
}
}
}
deleted &= file.delete();
if (!deleted) {
LOGGER.error("Coulnd't delete " + file);
return deleted;
}
return deleted;
Comments