HerdFileUtils extends FileUtils { public static void cleanDirectoryIgnoreException(File directory) { try { FileUtils.cleanDirectory(directory); } catch (Exception e) { LOGGER.warn(String.format("Failed to clean \"%s\" directory.", directory), e); } }  static void verifyFileExistsAndReadable(File file); static void cleanDirectoryIgnoreException(File directory); static void deleteDirectoryIgnoreException(File directory); static void deleteFileIgnoreException(File file); static final long BYTES_PER_GB; }
@Test public void testCleanDirectoryIgnoreException() throws IOException { File testFile = createLocalFile(localTempPath.toString(), "SOME_FILE", FILE_SIZE_1_KB); HerdFileUtils.cleanDirectoryIgnoreException(localTempPath.toFile()); assertFalse(testFile.exists()); assertTrue(localTempPath.toFile().exists()); }
@Test public void testCleanDirectoryIgnoreExceptionWithException() throws Exception { final File testFile = createLocalFile(localTempPath.toString(), "SOME_FILE", FILE_SIZE_1_KB); executeWithoutLogging(HerdFileUtils.class, new Command() { @Override public void execute() throws Exception { HerdFileUtils.cleanDirectoryIgnoreException(testFile); } }); assertTrue(testFile.exists()); }