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.jdom.word.playdough.model.DefaultCacheHandler.java

public void setCacheStatus(boolean status) {
    if (status) {
        try {//from  ww w .  j  ava2  s  .  com
            FileUtils.write(new File(directory, "cacheStatus"), "" + status);
        } catch (IOException e) {
            throw new IllegalStateException(e);
        }
    } else {
        FileUtils.deleteQuietly(new File(directory, "cacheStatus"));
    }
}

From source file:com.datatorrent.lib.util.TestUtils.java

public static void deleteTargetTestClassFolder(Description description) {
    FileUtils.deleteQuietly(new File("target/" + description.getClassName()));
}

From source file:com.sarm.lonelyplanet.process.LPUnMarshallerTest.java

/**
 * Deleting the TestFolder where the output from the Test cases were created
 *//*from w  ww.  ja  va 2s .c  o  m*/
@AfterClass
public static void tearDownClass() {
    logger.info("Tearing down LPUnMarshallerTest and deleting  " + targetLocation + "  folder");

    File file2 = new File(targetLocation);
    FileUtils.deleteQuietly(file2);
}

From source file:cz.cas.lib.proarc.common.export.mets.JhoveContext.java

/**
 * Removes temporary resources.
 */
public void destroy() {
    jhoveApp = null;
    jhoveBase = null;
    FileUtils.deleteQuietly(jhoveConfig);
}

From source file:com.linkedin.pinot.segments.v1.creator.IntArraysTest.java

@BeforeClass
public static void before() throws Exception {
    final String filePath = TestUtils
            .getFileFromResourceUrl(DictionariesTest.class.getClassLoader().getResource(AVRO_DATA));
    if (INDEX_DIR.exists()) {
        FileUtils.deleteQuietly(INDEX_DIR);
    }/*ww  w  .j  a va2  s.com*/

    System.out.println(INDEX_DIR.getAbsolutePath());
    final SegmentIndexCreationDriver driver = SegmentCreationDriverFactory.get(null);

    final SegmentGeneratorConfig config = SegmentTestUtils.getSegmentGenSpecWithSchemAndProjectedColumns(
            new File(filePath), INDEX_DIR, "weeksSinceEpochSunday", TimeUnit.DAYS, "test");
    config.setTimeColumnName("weeksSinceEpochSunday");
    driver.init(config);
    driver.build();

    final DataFileStream<GenericRecord> avroReader = AvroUtils.getAvroReader(new File(filePath));
    final org.apache.avro.Schema avroSchema = avroReader.getSchema();
    final String[] columns = new String[avroSchema.getFields().size()];
    int i = 0;
    for (final Field f : avroSchema.getFields()) {
        columns[i] = f.name();
        i++;
    }
}

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

@Override
public boolean delete(URI segmentUri) throws IOException {
    File file = new File(segmentUri);
    if (file.isDirectory()) {
        // Throws an IOException if it is unable to delete
        FileUtils.deleteDirectory(file);
    } else {/*from  w w  w . ja v  a2 s.c  om*/
        // Returns false if delete fails
        return FileUtils.deleteQuietly(file);
    }
    return true;
}

From source file:hoot.services.controllers.job.JobFieldsValidatorTest.java

@AfterClass
public static void afterClass() throws Exception {
    FileUtils.deleteQuietly(testFolder);
    HootCustomPropertiesSetter.setProperty("HOME_FOLDER", originalHomeFolderDir);
}

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

@Test
public void testFromHttpURI() throws IOException, URISyntaxException {
    //Given/*  ww  w  .j  a  v  a  2  s  .c om*/
    Path outputDirectory = Paths.get("build/test/asciidoc/fromUri");
    FileUtils.deleteQuietly(outputDirectory.toFile());

    //When
    Swagger2MarkupConverter.from(URI.create("http://petstore.swagger.io/v2/swagger.json")).build()
            .toFolder(outputDirectory);

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

From source file:com.diona.videoplugin.CameraUtil.java

/**
 * Method to get the photo from the camera.
 * /* w ww  .j  a  v  a  2 s .c  om*/
 * @param fragment
 *          fragment instance that holds the callback method for the camera utility
 */
public static void getPhotoFromCamera(final Fragment fragment) {
    final File imageFile = FileCacheUtil.getOutputMediaFile();
    if (imageFile != null && imageFile.exists()) {
        FileUtils.deleteQuietly(imageFile);
    }
    callingActivity = fragment;
    final Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);

    intent.putExtra(MediaStore.EXTRA_OUTPUT, Uri.fromFile(imageFile));

    // start the image capture Intent
    callingActivity.startActivityForResult(intent, CAMERA_REQUEST);
}

From source file:eu.delving.metadata.Hasher.java

public static File ensureFileHashed(File file) throws IOException {
    if (file.getName().contains(SEPARATOR)) {
        return file;
    } else {//from   www .ja v a 2s.  co  m
        Hasher hasher = new Hasher();
        hasher.update(file);
        File hashedFile = new File(file.getParentFile(), hasher.prefixFileName(file.getName()));
        if (hashedFile.exists())
            FileUtils.deleteQuietly(hashedFile);
        FileUtils.moveFile(file, hashedFile);
        return hashedFile;
    }
}