Create FileUtils#delete and write tests for FileUtils

This commit is contained in:
ljacqu
2016-09-17 00:42:18 +02:00
parent 0aa02b70f0
commit bdf8819aa7
4 changed files with 150 additions and 7 deletions
@@ -68,7 +68,22 @@ public final class FileUtils {
if (target.isDirectory()) {
purgeDirectory(target);
}
target.delete();
delete(target);
}
}
/**
* Delete the given file or directory and log a message if it was unsuccessful.
* Method is null safe and does nothing when null is passed.
*
* @param file the file to delete
*/
public static void delete(File file) {
if (file != null) {
boolean result = file.delete();
if (!result) {
ConsoleLogger.warning("Could not delete file '" + file + "'");
}
}
}
}