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.github.badamowicz.sonar.hla.impl.DefaultSonarConverterAggregatedTest.java

@AfterClass
public void cleanUp() {

    FileUtils.deleteQuietly(csvFile);
}

From source file:com.sarm.lonelyplanet.common.GeoUtilsTest.java

@AfterClass
public static void tearDownClass() {

    logger.info("Tearing down GeoUtilsTest and deleting the sample_destination.html file");
    File file = new File(sampleDestinationHtml);

    FileUtils.deleteQuietly(file);

}

From source file:fr.sanofi.fcl4transmart.controllers.listeners.geneExpression.RemoveRawFileListener.java

@Override
public void handleEvent(Event event) {
    Vector<File> files = this.selectRawFilesUI.getSelectedRemovedFile();
    if (files.size() < 1) {
        this.selectRawFilesUI.displayMessage("No file selected");
        return;/*  w ww  .  ja v a 2 s  .c  om*/
    }
    File mapping = ((GeneExpressionData) this.dataType).getStsmf();
    boolean confirm = this.selectRawFilesUI.confirm(
            "The column mapping file and the word mapping file will be removed consequently.\nAre you sure to remove these files?");
    for (File file : files) {
        if (file == null) {
            return;
        }
        if (((GeneExpressionData) this.dataType).getRawFiles().size() == files.size()) {
            if (mapping != null) {
                if (confirm) {
                    ((GeneExpressionData) this.dataType).setSTSMF(null);
                    try {
                        FileUtils.forceDelete(mapping);
                    } catch (IOException e) {
                        // TODO Auto-generated catch block
                        this.selectRawFilesUI.displayMessage("File error: " + e.getLocalizedMessage());
                        e.printStackTrace();
                    }

                    ((GeneExpressionData) this.dataType).getRawFiles().remove(file);
                    FileUtils.deleteQuietly(file);
                    UsedFilesPart.sendFilesChanged(dataType);
                }
            } else {
                if (confirm) {
                    ((GeneExpressionData) this.dataType).getRawFiles().remove(file);
                    FileUtils.deleteQuietly(file);
                    UsedFilesPart.sendFilesChanged(dataType);
                }
            }
        }
    }
    this.selectRawFilesUI.updateViewer();
    WorkPart.updateSteps();
    WorkPart.updateFiles();
}

From source file:com.samczsun.helios.transformers.disassemblers.BaksmaliDisassembler.java

public boolean disassembleClassNode(ClassNode cn, byte[] b, StringBuilder output) {
    File tempDir = null;// www . j  a  v a2 s  .  c o  m
    File tempClass = null;
    File tempZip = null;
    File tempDex = null;
    File tempSmali = null;
    try {
        tempDir = Files.createTempDirectory("smali").toFile();
        tempClass = new File(tempDir, "temp.class");
        tempZip = new File(tempDir, "temp.jar");
        tempDex = new File(tempDir, "temp.dex");
        tempSmali = new File(tempDir, "temp-smali");
        FileOutputStream fos = new FileOutputStream(tempClass);
        fos.write(b);
        fos.close();

        ZipUtil.packEntry(tempClass, tempZip);

        Converter.ENJARIFY.convert(tempZip, tempDex);

        org.jf.baksmali.main
                .main(new String[] { "-o", tempSmali.getAbsolutePath(), "-x", tempDex.getAbsolutePath() });

        File outputSmali = null;

        boolean found = false;
        File current = tempSmali;
        while (!found) {
            File f = current.listFiles()[0];
            if (f.isDirectory())
                current = f;
            else {
                outputSmali = f;
                found = true;
            }

        }
        output.append(FileUtils.readFileToString(outputSmali, "UTF-8"));
        return true;
    } catch (SecurityException e) {
        return false;
    } catch (final Exception e) {
        ExceptionHandler.handle(e);
        return false;
    } finally {
        FileUtils.deleteQuietly(tempDir);
        FileUtils.deleteQuietly(tempClass);
        FileUtils.deleteQuietly(tempZip);
        FileUtils.deleteQuietly(tempDex);
        FileUtils.deleteQuietly(tempSmali);
    }
}

From source file:is.iclt.jcorpald.CorpaldModel.java

private String getTempQueryPath() {
    String filename = System.getProperty("user.home") + "/temp.q";
    FileUtils.deleteQuietly(new File(filename));
    return filename;
}

From source file:its.ConnectedModeRequirementsTest.java

@Before
public void start() {
    FileUtils.deleteQuietly(sonarUserHome.toFile());
    engine = new ConnectedSonarLintEngineImpl(ConnectedGlobalConfiguration.builder().setServerId("orchestrator")
            .setSonarLintUserHome(sonarUserHome).setLogOutput((msg, level) -> System.out.println(msg)).build());
    assertThat(engine.getGlobalStorageStatus()).isNull();
    assertThat(engine.getState()).isEqualTo(State.NEVER_UPDATED);
}

From source file:com.linkedin.pinot.tools.admin.command.StarTreeOnHeapToOffHeapConverter.java

@Override
public boolean execute() throws Exception {
    File indexDir = new File(_segmentDir);
    long start = System.currentTimeMillis();

    LOGGER.info("Loading segment {}", indexDir.getName());
    IndexSegment segment = Loaders.IndexSegment.load(indexDir, ReadMode.heap);

    long end = System.currentTimeMillis();
    LOGGER.info("Loaded segment {} in {} ms ", indexDir.getName(), (end - start));

    start = end;/*from w ww.j  a  v  a 2 s.  c o m*/
    StarTreeInterf starTreeOnHeap = segment.getStarTree();
    File starTreeOffHeapFile = new File(TMP_DIR,
            (V1Constants.STAR_TREE_INDEX_FILE + System.currentTimeMillis()));

    // Convert the star tree on-heap to off-heap format.
    StarTreeSerDe.writeTreeOffHeapFormat(starTreeOnHeap, starTreeOffHeapFile);

    // Copy all the indexes into output directory.
    File outputDir = new File(_outputDir);
    FileUtils.deleteQuietly(outputDir);
    FileUtils.copyDirectory(indexDir, outputDir);

    // Delete the existing star tree on-heap file from the output directory.
    FileUtils.deleteQuietly(new File(_outputDir, V1Constants.STAR_TREE_INDEX_FILE));

    // Move the temp star tree off-heap file into the output directory.
    FileUtils.moveFile(starTreeOffHeapFile, new File(_outputDir, V1Constants.STAR_TREE_INDEX_FILE));
    end = System.currentTimeMillis();

    LOGGER.info("Converted segment: {} ms", (end - start));
    return true;
}

From source file:its.tools.SonarlintDaemon.java

@Override
protected void after() {
    if (exec != null) {
        exec.destroy();/*from   w  w w.  jav  a 2  s . c om*/
        exec = null;
    }
    if (installPath != null) {
        FileUtils.deleteQuietly(installPath.toFile());
        installPath = null;
    }
}

From source file:com.linkedin.pinot.server.api.resources.BaseResourceTest.java

@BeforeClass
public void setUp() throws Exception {
    FileUtils.deleteQuietly(INDEX_DIR);
    Assert.assertTrue(INDEX_DIR.mkdirs());
    URL resourceUrl = getClass().getClassLoader().getResource(AVRO_DATA_PATH);
    Assert.assertNotNull(resourceUrl);/*from ww  w  .  j  av a  2  s .c o  m*/
    _avroFile = new File(resourceUrl.getFile());

    // Mock the instance data manager
    InstanceDataManager instanceDataManager = mock(InstanceDataManager.class);
    when(instanceDataManager.getTableDataManager(anyString())).thenAnswer(new Answer<TableDataManager>() {
        @SuppressWarnings("SuspiciousMethodCalls")
        @Override
        public TableDataManager answer(InvocationOnMock invocation) throws Throwable {
            return _tableDataManagerMap.get(invocation.getArguments()[0]);
        }
    });
    when(instanceDataManager.getTableDataManagers()).thenReturn(_tableDataManagerMap.values());

    // Mock the server instance
    ServerInstance serverInstance = mock(ServerInstance.class);
    when(serverInstance.getInstanceDataManager()).thenReturn(instanceDataManager);

    // Add the default table and segment
    addTable(TABLE_NAME);
    setUpSegment("default");

    _adminApiApplication = new AdminApiApplication(serverInstance);
    _adminApiApplication.start(CommonConstants.Server.DEFAULT_ADMIN_API_PORT);
    _webTarget = ClientBuilder.newClient().target(_adminApiApplication.getBaseUri());
}

From source file:io.github.swagger2markup.AsciidocConverterTest.java

@Test
public void testToFolder() throws IOException, URISyntaxException {
    //Given//  ww w.  jav a  2 s  .c o  m
    Path file = Paths.get(AsciidocConverterTest.class.getResource("/yaml/swagger_petstore.yaml").toURI());
    Path outputDirectory = Paths.get("build/test/asciidoc/to_folder");
    FileUtils.deleteQuietly(outputDirectory.toFile());

    //When
    Swagger2MarkupConverter.from(file).build().toFolder(outputDirectory);

    //Then
    String[] files = outputDirectory.toFile().list();
    assertThat(files).hasSize(4).containsAll(expectedFiles);

    Path expectedFilesDirectory = Paths
            .get(AsciidocConverterTest.class.getResource("/expected/asciidoc/to_folder").toURI());
    DiffUtils.assertThatAllFilesAreEqual(expectedFilesDirectory, outputDirectory, "testToFolder.html");
}