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:fr.lirmm.graphik.graal.bench.homomorphism.BenchUtils.java

public static Store getStoreSat(String system, String basename) throws AtomSetException, DriverException {
    if ("SQLITE".equals(system)) {
        if (SQLITE_SEMISAT.exists())
            FileUtils.deleteQuietly(SQLITE_SEMISAT);
        return new DefaultRdbmsStore(new SqliteDriver(SQLITE_SEMISAT));
    } else {/*from ww w . j  a  v  a 2 s  . c  o m*/
        return new DefaultRdbmsStore(new MysqlDriver(String.format(MYSQL_SEMISAT, basename)));
    }
}

From source file:com.linkedin.pinot.index.readerwriter.VarByteChunkSingleValueReaderWriteTest.java

/**
 * This test writes {@link #NUM_STRINGS} using {@link VarByteChunkSingleValueWriter}. It then reads
 * the strings using {@link VarByteChunkSingleValueReader}, and asserts that what was written is the same as
 * what was read in.//  w ww  .j a va2s .c  om
 *
 * Number of docs and docs per chunk are chosen to generate complete as well partial chunks.
 *
 * @throws Exception
 */
@Test
public void test() throws Exception {
    String[] expected = new String[NUM_STRINGS];
    Random random = new Random();

    File outFile = new File(TEST_FILE);
    FileUtils.deleteQuietly(outFile);

    int maxStringLengthInBytes = 0;
    for (int i = 0; i < NUM_STRINGS; i++) {
        expected[i] = RandomStringUtils.random(random.nextInt(MAX_STRING_LENGTH));
        maxStringLengthInBytes = Math.max(maxStringLengthInBytes, expected[i].getBytes(UTF_8).length);
    }

    ChunkCompressor compressor = ChunkCompressorFactory.getCompressor("snappy");
    VarByteChunkSingleValueWriter writer = new VarByteChunkSingleValueWriter(outFile, compressor, NUM_STRINGS,
            NUM_DOCS_PER_CHUNK, maxStringLengthInBytes);

    for (int i = 0; i < NUM_STRINGS; i++) {
        writer.setString(i, expected[i]);
    }
    writer.close();

    PinotDataBuffer pinotDataBuffer = PinotDataBuffer.fromFile(outFile, ReadMode.mmap,
            FileChannel.MapMode.READ_ONLY, getClass().getName());

    ChunkDecompressor uncompressor = ChunkCompressorFactory.getDecompressor("snappy");
    VarByteChunkSingleValueReader reader = new VarByteChunkSingleValueReader(pinotDataBuffer, uncompressor);
    ChunkReaderContext context = reader.createContext();

    for (int i = 0; i < NUM_STRINGS; i++) {
        String actual = reader.getString(i, context);
        Assert.assertEquals(actual, expected[i]);
    }
    reader.close();
    FileUtils.deleteQuietly(outFile);
}

From source file:com.linkedin.pinot.core.segment.index.SegmentMetadataImplTest.java

@AfterMethod
public void tearDown() {
    FileUtils.deleteQuietly(segmentDirectory);
}

From source file:it.drwolf.ridire.utility.RIDIREPlainTextCleaner.java

public void cleanTextFile(File f) throws IOException {
    File tmpFile = new File(f.getCanonicalPath() + ".tmp");
    FileUtils.writeStringToFile(tmpFile, this.getCleanText(f));
    FileUtils.deleteQuietly(f);
    FileUtils.moveFile(tmpFile, f);/*from  w w  w  .ja va 2s  .c  om*/
}

From source file:com.linkedin.pinot.index.readerwriter.FixedByteChunkSingleValueReaderWriteTest.java

@Test
public void testInt() throws Exception {
    int[] expected = new int[NUM_VALUES];
    for (int i = 0; i < NUM_VALUES; i++) {
        expected[i] = _random.nextInt();
    }//  w w w . ja va 2 s .  c  om

    File outFile = new File(TEST_FILE);
    FileUtils.deleteQuietly(outFile);

    ChunkCompressor compressor = ChunkCompressorFactory.getCompressor("snappy");
    FixedByteChunkSingleValueWriter writer = new FixedByteChunkSingleValueWriter(outFile, compressor,
            NUM_VALUES, NUM_DOCS_PER_CHUNK, V1Constants.Numbers.INTEGER_SIZE);

    for (int i = 0; i < NUM_VALUES; i++) {
        writer.setInt(i, expected[i]);
    }
    writer.close();

    PinotDataBuffer pinotDataBuffer = PinotDataBuffer.fromFile(outFile, ReadMode.mmap,
            FileChannel.MapMode.READ_ONLY, getClass().getName());

    ChunkDecompressor uncompressor = ChunkCompressorFactory.getDecompressor("snappy");
    FixedByteChunkSingleValueReader reader = new FixedByteChunkSingleValueReader(pinotDataBuffer, uncompressor);
    ChunkReaderContext context = reader.createContext();

    for (int i = 0; i < NUM_VALUES; i++) {
        int actual = reader.getInt(i, context);
        Assert.assertEquals(actual, expected[i]);
    }
    reader.close();
    FileUtils.deleteQuietly(outFile);
}

From source file:com.openkm.jcr.CleanUnusedTest.java

@Override
protected void tearDown() {
    log.info("tearDown()");
    log.info("Delete repository: {}", TestConfig.REPOSITORY_HOME);
    FileUtils.deleteQuietly(new File(TestConfig.REPOSITORY_HOME));
}

From source file:com.strandls.alchemy.rest.client.stubgenerator.ProxyImplementationGeneratorTest.java

/**
 * Test method for/*from www.  ja va2  s. com*/
 * {@link com.strandls.alchemy.rest.client.stubgenerator.ProxyImplementationGenerator#generateProxy(java.lang.String, java.lang.String, java.lang.String, java.io.File)}
 * .
 *
 * @throws IOException
 */
@Test
public void testGenerateProxyWithPackage() throws IOException {
    final ProxyImplementationGenerator generator = new ProxyImplementationGenerator();
    final File tempDir = File.createTempFile("test", "test");
    FileUtils.deleteQuietly(tempDir);

    if (!tempDir.mkdirs()) {
        throw new IOException("Cannot create temporary directory.");
    }
    try {
        generator.generateProxy("TestStub", "TestStubProxyWithPackage", "com.strandls.alchemy.client", tempDir);
        assertEquals(
                FileUtils.readFileToString(
                        new File("src/test/resources/com/strandls/alchemy/rest/client/stubgenerator"
                                + "/TestStubProxyWithPackage.txt"))
                        .trim(),
                FileUtils.readFileToString(new File(tempDir, "TestStubProxyWithPackage.java")).trim());
    } finally {
        FileUtils.deleteQuietly(tempDir);
    }
}

From source file:com.adaptris.util.stream.StreamUtilTest.java

@Test
public void testCreateFileInDirectory2() throws Exception {
    int bytes = TEXT.length();
    ByteArrayInputStream in = new ByteArrayInputStream(TEXT.getBytes());
    File f = StreamUtil.createFile(in, bytes, "");
    assertNotNull(f);//from www  . j  a  v  a 2  s .c o  m
    assertEquals(TEXT, new String(read(f)));
    FileUtils.deleteQuietly(f);
}

From source file:com.thoughtworks.go.server.cache.ZipArtifactCacheTest.java

@After
public void tearDown() throws Exception {
    FileUtils.deleteQuietly(folder);
}

From source file:com.splunk.shuttl.archiver.usecases.FlusherFunctionalTest.java

@AfterMethod
public void tearDown() {
    FileUtils.deleteQuietly(tmp);
    FileUtils.deleteQuietly(thawDir);
}