Example usage for org.apache.commons.io FileUtils deleteQuietly

List of usage examples for org.apache.commons.io FileUtils deleteQuietly

Introduction

In this page you can find the example usage for org.apache.commons.io FileUtils deleteQuietly.

Prototype

public static boolean deleteQuietly(File file) 

Source Link

Document

Deletes a file, never throwing an exception.

Usage

From source file:com.linkedin.pinot.core.segment.store.SingleFileIndexDirectoryTest.java

@BeforeMethod
public void setUpTest() throws IOException, ConfigurationException {
    segmentDir = new File(TEST_DIRECTORY, "segmentDirectory");

    if (segmentDir.exists()) {
        FileUtils.deleteQuietly(segmentDir);
    }// w  ww  .  j a  v a  2  s  .co m
    segmentDir.mkdirs();
    segmentDir.deleteOnExit();
    writeMetadata();
}

From source file:com.creactiviti.piper.plugin.ffmpeg.Vstitch.java

@Override
public Object handle(Task aTask) throws Exception {
    List<String> chunks = aTask.getList("chunks", String.class);
    File tempFile = File.createTempFile("_chunks", ".txt");
    try {//from   w ww .ja va 2  s  .  c  o m
        try (Writer writer = new BufferedWriter(
                new OutputStreamWriter(new FileOutputStream(tempFile, true), "UTF-8"))) {
            for (String chunk : chunks) {
                writer.append(String.format("file '%s'", chunk)).append("\n");
            }
        }
        SimpleTaskExecution ffmpegTask = SimpleTaskExecution.create();
        List<String> options = Arrays.asList("-y", "-f", "concat", "-safe", "0", "-i",
                tempFile.getAbsolutePath(), "-c", "copy", aTask.getRequiredString("output"));
        ffmpegTask.set("options", options);
        ffmpeg.handle(ffmpegTask);
    } finally {
        FileUtils.deleteQuietly(tempFile);
    }
    return null;
}

From source file:gov.nih.nci.caarray.application.fileaccess.FileCleanupThread.java

/**
 * Attempts to delete all files in the filesToRemove list. If the file is
 * successfully deleted or does not exist it will be removed from the
 * filesToRemove list. If unsuccessful in deleting the file it will remain
 * in the filesToRemove list./*  www . j  av  a 2 s .  com*/
 */
public void deleteFiles() {
    LOG.info("Removing " + filesToRemove.size() + " files");
    if (!filesToRemove.isEmpty()) {
        ArrayList<File> filesRemoved = new ArrayList<File>();
        for (File file : filesToRemove) {
            if (file.exists() && !FileUtils.deleteQuietly(file)) {
                LOG.warn("Still unable to delete file: " + file.getAbsolutePath());
            } else {
                filesRemoved.add(file);
                LOG.info("Deleted file: " + file.getAbsolutePath());
            }
        }
        filesToRemove.removeAll(filesRemoved);
    }
}

From source file:com.github.exper0.efilecopier.ftp.TestSuite.java

@AfterClass
public static void shutDown() {
    server.stop();/* w  w  w.  j av  a 2s  .  c om*/
    FileUtils.deleteQuietly(new File(FTP_ROOT_DIR));
    FileUtils.deleteQuietly(new File(LOCAL_FTP_TEMP_DIR));
}

From source file:fr.acxio.tools.agia.tasks.ZipFilesTaskletTest.java

@After
public void tearDown() throws Exception {
    Collection<File> aFilesToDelete = FileUtils.listFiles(new File("target"),
            new WildcardFileFilter("Z*-input*.zip"), null);
    for (File aFile : aFilesToDelete) {
        aFile.setWritable(true);/*from   www  .  j  a  v a 2s .com*/
        FileUtils.deleteQuietly(aFile);
    }
    FileUtils.deleteDirectory(new File("target/Z-testfiles"));
}

From source file:com.cloud.servlet.StaticResourceServletTest.java

@After
public void cleanupFiles() {
    FileUtils.deleteQuietly(rootDirectory);
}

From source file:com.siberhus.tdfl.DflBaseTest.java

@AfterClass
public static void deleteGeneratedFiles() {
    FileUtils.deleteQuietly(new File(XLS_FILE_IN_NAME));
}

From source file:com.linkedin.pinot.filesystem.LocalPinotFS.java

@Override
public boolean copy(URI srcUri, URI dstUri) throws IOException {
    File srcFile = new File(srcUri);
    File dstFile = new File(dstUri);
    if (dstFile.exists()) {
        FileUtils.deleteQuietly(dstFile);
    }//from  w  ww . j  a v a  2s.c  o  m
    if (srcFile.isDirectory()) {
        // Throws Exception on failure
        FileUtils.copyDirectory(srcFile, dstFile);
    } else {
        // Will create parent directories, throws Exception on failure
        FileUtils.copyFile(srcFile, dstFile);
    }
    return true;
}

From source file:com.github.technosf.posterer.modules.commons.config.CommonsConfiguratorPropertiesImplTest.java

/**
 * Delete the CUT/*from   w w w. j a v a 2s .  c  o  m*/
 */
@AfterClass
public final void afterClass() throws IOException {
    FileUtils.deleteQuietly(getFile(classUnderTest.pathPropsFile()));
}

From source file:com.thoughtworks.go.config.ConfigMigrator.java

public static GoConfigHolder loadWithMigration(InputStream input,
        final ConfigElementImplementationRegistry registry) throws Exception {
    File tempFile = TestFileUtil.createTempFile("cruise-config.xml");
    try {//w  w  w.j a  v a 2 s .com
        MagicalGoConfigXmlLoader xmlLoader = new MagicalGoConfigXmlLoader(new ConfigCache(), registry);
        FileUtils.copyInputStreamToFile(input, tempFile);
        migrate(tempFile);
        return xmlLoader.loadConfigHolder(FileUtils.readFileToString(tempFile, UTF_8));
    } finally {
        FileUtils.deleteQuietly(tempFile);
    }
}