AdeFileUtils { public static boolean deleteRecursiveOrLog(File path) { if (path.isDirectory()) { boolean success = true; final File[] files = path.listFiles(); for (File file : files) { success = deleteRecursiveOrLog(file) && success; } if (!success) { logger.warn("Cannot delete " + path.getPath() + ": failed to delete all files inside"); return false; } } if (!path.delete()) { logger.warn(FAILED_DELETING_FILE + path.getPath()); return false; } return true; } private  AdeFileUtils(); static void copyFile(File source, File target); static BufferedReader openLogFile(File file); static InputStream openLogFileAsInputStream(File file); static void deleteFile(File file); static void deleteFileOrLog(File file); static void createDir(File target); static void createDirs(File target); static boolean deleteRecursiveOrLog(File path);  }
@Test public void testDeleteRecursiveOrLog() throws IOException, AdeUsageException { final File targetDir = temporaryFolder.newFolder("dir1"); assertTrue("Returns true if successfully deleted.", AdeFileUtils.deleteRecursiveOrLog(targetDir)); }
@Test public void testDeleteRecursiveOrLogNotDir() throws IOException, AdeUsageException { final File targetFile = temporaryFolder.newFile(); assertTrue("Returns true if successfully deleted.", AdeFileUtils.deleteRecursiveOrLog(targetFile)); }