/** * Deletes the file object. * <p> * This implementation uses <code>FileUtils.forceDelete()</code> * if the file exists. * * @param fileToDelete the file to delete, not null * @return Always returns {@code true} * @throws NullPointerException if the file is null * @throws IOException if an error occurs during file deletion */ @Override protected boolean doDelete(final File fileToDelete) throws IOException { FileUtils.forceDelete(fileToDelete); return true; } }
public static void rmr(String path) throws IOException { LOG.debug("Rmr path " + path); if (exists_file(path)) { FileUtils.forceDelete(new File(path)); } }
public void deleteVersion(long version) throws IOException { File versionFile = new File(versionPath(version)); File tokenFile = new File(tokenPath(version)); if (tokenFile.exists()) { FileUtils.forceDelete(tokenFile); } if (versionFile.exists()) { FileUtils.forceDelete(versionFile); } }
public static void rmr(String path) throws IOException { LOG.debug("Rmr path " + path); if (exists_file(path)) { FileUtils.forceDelete(new File(path)); } }
/** * Cleans a directory without deleting it. * * @param directory directory to clean * @throws IOException in case cleaning is unsuccessful * @throws IllegalArgumentException if {@code directory} does not exist or is not a directory */ public static void cleanDirectory(final File directory) throws IOException { final File[] files = verifiedListFiles(directory); IOException exception = null; for (final File file : files) { try { forceDelete(file); } catch (final IOException ioe) { exception = ioe; } } if (null != exception) { throw exception; } }
private void cleanupSessionLogDir() { // In case of test, if we might not want to remove the log directory if (isOperationLogEnabled && sessionConf.getBoolVar(ConfVars.HIVE_TESTING_REMOVE_LOGS)) { try { FileUtils.forceDelete(sessionLogDir); LOG.info("Operation log session directory is deleted: " + sessionLogDir.getAbsolutePath()); } catch (Exception e) { LOG.error("Failed to cleanup session log dir: " + sessionHandle, e); } } }
private void destroyBuffer(PinotDataBuffer buffer, File mmapFile) throws IOException { if (buffer != null) { buffer.close(); if (mmapFile.exists()) { FileUtils.forceDelete(mmapFile); } } } }
public static File newFile(final File testDirectory, final String filename) throws IOException { final File destination = new File(testDirectory, filename); /* assertTrue( filename + "Test output data file shouldn't previously exist", !destination.exists() ); */ if (destination.exists()) { FileUtils.forceDelete(destination); } return destination; }
@AfterClass public static void teardown() throws IOException { FileUtils.forceDelete(TEST_DIR); for (File dir : FIREHOSE_TMP_DIRS) { FileUtils.forceDelete(dir); } }
private File createFirehoseTmpDir(String dirSuffix) throws IOException { final File firehoseTempDir = File.createTempFile( SqlFirehoseFactoryTest.class.getSimpleName(), dirSuffix ); FileUtils.forceDelete(firehoseTempDir); FileUtils.forceMkdir(firehoseTempDir); FIREHOSE_TMP_DIRS.add(firehoseTempDir); return firehoseTempDir; }
@BeforeClass public static void setup() throws IOException { TEST_DIR = File.createTempFile(SqlFirehoseFactoryTest.class.getSimpleName(), "testDir"); FileUtils.forceDelete(TEST_DIR); FileUtils.forceMkdir(TEST_DIR); }
@After public void teardown() throws IOException { FileUtils.forceDelete(TEST_DIR); }
@After public void teardown() throws IOException { inputStream.close(); FileUtils.forceDelete(testFile); }
@Test public void testForceDeleteAFile1() throws Exception { final File destination = new File(getTestDirectory(), "copy1.txt"); destination.createNewFile(); assertTrue("Copy1.txt doesn't exist to delete", destination.exists()); FileUtils.forceDelete(destination); assertTrue("Check No Exist", !destination.exists()); }
@Test public void testForceDeleteAFile2() throws Exception { final File destination = new File(getTestDirectory(), "copy2.txt"); destination.createNewFile(); assertTrue("Copy2.txt doesn't exist to delete", destination.exists()); FileUtils.forceDelete(destination); assertTrue("Check No Exist", !destination.exists()); }
@AfterClass public static void tearDownAfterClass() throws KettleException, IOException { if ( repo != null ) { repo.disconnect(); } FileUtils.forceDelete( new File( baseDirName.toString() ) ); }
@Test public void testForceDeleteAFile3() throws Exception { final File destination = new File(getTestDirectory(), "no_such_file"); assertTrue("Check No Exist", !destination.exists()); try { FileUtils.forceDelete(destination); fail("Should generate FileNotFoundException"); } catch (final FileNotFoundException ignored) { } }
@Test public void testForceDeleteDir() throws Exception { final File testDirectory = getTestDirectory(); assertTrue("TestDirectory must exist", testDirectory.exists()); FileUtils.forceDelete(testDirectory); assertFalse("TestDirectory must not exist", testDirectory.exists()); }
@Test public void create_temp_dir_if_missing() throws Exception { ServerFileSystem fs = mock(ServerFileSystem.class); File tmpDir = temp.newFolder(); when(fs.getTempDir()).thenReturn(tmpDir); FileUtils.forceDelete(tmpDir); TempFolder folder = underTest.provide(fs); assertThat(folder).isNotNull(); File newDir = folder.newDir(); assertThat(newDir).exists().isDirectory(); assertThat(newDir.getParentFile().getCanonicalPath()).startsWith(tmpDir.getCanonicalPath()); } }
@Test public void read_file_fails_if_file_does_not_exist() throws Exception { thrown.expect(ContextException.class); thrown.expectMessage("Unable to read message"); File file = temp.newFile(); FileUtils.forceDelete(file); Protobuf.read(file, Fake.parser()); }