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.thoughtworks.go.config.materials.svn.SvnMultipleMaterialsTest.java

@After
public void cleanupRepo() {
    repo.tearDown();
    FileUtils.deleteQuietly(pipelineDir);
}

From source file:com.haulmont.cuba.core.sys.logging.LogArchiver.java

public static void writeArchivedLogToStream(File logFile, OutputStream outputStream) throws IOException {
    if (!logFile.exists()) {
        throw new FileNotFoundException();
    }/*  ww w .j ava  2 s.c o m*/

    File tempFile = File.createTempFile(FilenameUtils.getBaseName(logFile.getName()) + "_log_", ".zip");

    ZipArchiveOutputStream zipOutputStream = new ZipArchiveOutputStream(tempFile);
    zipOutputStream.setMethod(ZipArchiveOutputStream.DEFLATED);
    zipOutputStream.setEncoding(ZIP_ENCODING);

    ArchiveEntry archiveEntry = newArchive(logFile);
    zipOutputStream.putArchiveEntry(archiveEntry);

    FileInputStream logFileInput = new FileInputStream(logFile);
    IOUtils.copyLarge(logFileInput, zipOutputStream);

    logFileInput.close();

    zipOutputStream.closeArchiveEntry();
    zipOutputStream.close();

    FileInputStream tempFileInput = new FileInputStream(tempFile);
    IOUtils.copyLarge(tempFileInput, outputStream);

    tempFileInput.close();

    FileUtils.deleteQuietly(tempFile);
}

From source file:com.thoughtworks.go.config.materials.svn.SvnMaterialUpdaterTest.java

@AfterEach
void tearDown() {
    FileUtils.deleteQuietly(workingDir);
    TestRepo.internalTearDown();
}

From source file:gov.nih.nci.caarray.dataStorage.fileSystem.FileSystemDataStorageTest.java

@After
public void cleanupStorageDirectory() throws IOException {
    FileUtils.deleteQuietly(this.storageDir);
}

From source file:de.tor.tribes.util.MainShutdownHook.java

@Override
public synchronized void run() {
    if (hasRun) {
        return;//from ww w .j a  va 2 s .  c  o m
    }
    hasRun = true;
    try {
        logger.info("Performing ShutdownHook");
        if (!DataHolder.getSingleton().isDataValid()) {
            logger.error("Server data seems to be invalid. No user data will be stored!");
            return;
        }
        GlobalOptions.saveUserData();
        GlobalOptions.addProperty("layer.order", LayerOrderConfigurationFrame.getSingleton().getLayerOrder());
        DSWorkbenchMainFrame.getSingleton().storeProperties();
        GlobalOptions.saveProperties();
        GlobalOptions.storeViewStates();
        if (!FileUtils.deleteQuietly(new File(".running"))) {
            logger.warn("Failed to remove file '.running'");
        }
        logger.debug("Shutdown finished");
    } catch (Throwable t) {
        logger.error("Shutdown failed", t);
    }
    System.exit(0);
}

From source file:io.vertx.config.vault.utils.VaultProcess.java

public void initAndUnsealVault() {
    backend = null;/*w  ww  . j  a  v a  2 s  .  c  o m*/
    File stored = new File("target/vault/file");
    FileUtils.deleteQuietly(stored);
    startServer();
    init();
    unseal();
}

From source file:com.adaptris.core.lms.LargeFsMessageProducerTest.java

@Override
protected void tearDown() throws Exception {
    // delete contents of destination...
    FileUtils.deleteQuietly(baseDir);
    FileUtils.deleteQuietly(tempDir);/*from w ww .  ja va  2 s .c o m*/
    FileUtils.deleteQuietly(destDir);
}

From source file:com.sangupta.shire.site.SiteBackup.java

/**
 * Method to restore the _site.backup folder that we took in this very session.
 *///from  w w  w.  j  a  v a 2 s .co  m
private void restoreSiteBackup() {
    if (backupFolder != null) {
        // build up the name of the original folder
        String path = backupFolder.getAbsolutePath();
        path = StringUtils.left(path, path.length() - BACKUP_FOLDER_EXTENSION.length());
        File original = new File(path);

        // delete the currently made site folder
        if (original.exists()) {
            FileUtils.deleteQuietly(original);
        }

        // restore the backup
        try {
            FileUtils.moveDirectory(backupFolder, original);
        } catch (IOException e) {
            System.out.println("Unable to restore the original site backup.");
            e.printStackTrace();
        }
    }
}

From source file:com.unister.semweb.drums.file.SpecificEnlargmentTest.java

/** Initialise the test by removing the test file and initialisation the {@link DRUMSParameterSet}. */
@Before//from ww  w  . j a  va2 s.  c o  m
public void initialise() throws Exception {
    FileUtils.deleteQuietly(new File(filename));
    globalParameters = new DRUMSParameterSet<TestStorable>(new TestStorable());
    globalParameters.INITIAL_FILE_SIZE = 1 * MB;
    globalParameters.INITIAL_INCREMENT_SIZE = 1 * KB;
}

From source file:com.adaptris.core.runtime.FileLogHandlerJmxTest.java

@Override
protected void tearDown() throws Exception {
    FileUtils.deleteQuietly(LOG_DIRECTORY);
    FileUtils.deleteDirectory(LOG_DIRECTORY);
    super.tearDown();
}