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.query.selection.SelectionQueriesMVTest.java

@BeforeClass
public void setup() throws Exception {
    FileUtils.deleteQuietly(INDEX_DIR);

    // Get resource file path.
    URL resource = getClass().getClassLoader().getResource(AVRO_DATA);
    Assert.assertNotNull(resource);//from   w w w .j ava  2 s .  com
    String filePath = resource.getFile();

    // Build the index segment.
    SegmentGeneratorConfig config = SegmentTestUtils.getSegmentGenSpecWithSchemAndProjectedColumns(
            new File(filePath), INDEX_DIR, "daysSinceEpoch", TimeUnit.DAYS, "testTable");
    SegmentIndexCreationDriver driver = new SegmentIndexCreationDriverImpl();
    driver.init(config);
    driver.build();

    // Load the index segment.
    File indexSegmentDir = new File(INDEX_DIR, driver.getSegmentName());
    _indexSegment = ColumnarSegmentLoader.load(indexSegmentDir, ReadMode.heap);

    // Initialize the data source map.
    _dataSourceMap = new HashMap<>();
    _dataSourceMap.put("column1", _indexSegment.getDataSource("column1"));
    _dataSourceMap.put("column2", _indexSegment.getDataSource("column2"));
    _dataSourceMap.put("column6", _indexSegment.getDataSource("column6"));
    _dataSourceMap.put("count", _indexSegment.getDataSource("count"));

    // Build the selection ONLY query.
    _selectionOnlyQuery = new Selection();
    _selectionOnlyQuery.setSelectionColumns(Arrays.asList("column6", "column1", "count"));
    _selectionOnlyQuery.setSize(10);

    // Build the selection ORDER BY query.
    _selectionOrderByQuery = new Selection();
    _selectionOrderByQuery.setSelectionColumns(Arrays.asList("column6", "column1", "count"));
    _selectionOrderByQuery.setSize(10);
    SelectionSort selectionSort1 = new SelectionSort();
    selectionSort1.setColumn("column2");
    SelectionSort selectionSort2 = new SelectionSort();
    selectionSort2.setColumn("column1");
    _selectionOrderByQuery.setSelectionSortSequence(Arrays.asList(selectionSort1, selectionSort2));
}

From source file:com.linkedin.pinot.query.selection.SelectionQueriesSVTest.java

@BeforeClass
public void setup() throws Exception {
    FileUtils.deleteQuietly(INDEX_DIR);

    // Get resource file path.
    URL resource = getClass().getClassLoader().getResource(AVRO_DATA);
    Assert.assertNotNull(resource);//from   w ww .  jav a2 s.  c  o m
    String filePath = resource.getFile();

    // Build the index segment.
    SegmentGeneratorConfig config = SegmentTestUtils.getSegmentGenSpecWithSchemAndProjectedColumns(
            new File(filePath), INDEX_DIR, "time_day", TimeUnit.DAYS, "testTable");
    SegmentIndexCreationDriver driver = new SegmentIndexCreationDriverImpl();
    driver.init(config);
    driver.build();

    // Load the index segment.
    File indexSegmentDir = new File(INDEX_DIR, driver.getSegmentName());
    _indexSegment = ColumnarSegmentLoader.load(indexSegmentDir, ReadMode.heap);

    // Initialize the data source map.
    _dataSourceMap = new HashMap<>();
    _dataSourceMap.put("column11", _indexSegment.getDataSource("column11"));
    _dataSourceMap.put("column12", _indexSegment.getDataSource("column12"));
    _dataSourceMap.put("column13", _indexSegment.getDataSource("column13"));
    _dataSourceMap.put("met_impressionCount", _indexSegment.getDataSource("met_impressionCount"));

    // Build the selection ONLY query.
    _selectionOnlyQuery = new Selection();
    _selectionOnlyQuery.setSelectionColumns(Arrays.asList("column12", "column11", "met_impressionCount"));
    _selectionOnlyQuery.setSize(10);

    // Build the selection ORDER BY query.
    _selectionOrderByQuery = new Selection();
    _selectionOrderByQuery.setSelectionColumns(Arrays.asList("column12", "column11", "met_impressionCount"));
    _selectionOrderByQuery.setSize(10);
    SelectionSort selectionSort1 = new SelectionSort();
    selectionSort1.setColumn("column13");
    SelectionSort selectionSort2 = new SelectionSort();
    selectionSort2.setColumn("column11");
    _selectionOrderByQuery.setSelectionSortSequence(Arrays.asList(selectionSort1, selectionSort2));
}

From source file:com.thoughtworks.go.server.presentation.models.JobDetailPresentationModelJMockTest.java

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

From source file:com.streamsets.pipeline.stage.destination.TestMapReduceConfig.java

@Before
public void setUp() {
    config = new MapReduceConfig();
    config.mapReduceConfDir = confDir;/*from   ww w .  ja  va 2s .c om*/
    config.mapreduceConfigs = Collections.emptyMap();
    config.mapreduceUser = "doctor-who";
    config.kerberos = false;

    com.streamsets.pipeline.api.Configuration configuration = mock(
            com.streamsets.pipeline.api.Configuration.class);
    context = mock(Stage.Context.class);
    when(context.getConfiguration()).thenReturn(configuration);

    FileUtils.deleteQuietly(new File(confDir, "yarn-site.xml"));
    FileUtils.deleteQuietly(new File(confDir, "core-site.xml"));
    FileUtils.deleteQuietly(new File(confDir, "mapred-site.xml"));
    FileUtils.deleteQuietly(new File(confDir, "hdfs-site.xml"));
}

From source file:com.galenframework.tests.utils.GalenUtilsTest.java

@Test
public void shouldReadRelativePath() throws Exception {
    File baseDir = new File(System.getProperty("java.io.tmpdir"));
    File tempDir = new File(baseDir, "galen_test");
    tempDir.mkdir();/* w ww .ja v a 2s. c o  m*/
    File testFile1 = new File(tempDir, "testFile.txt");
    BufferedWriter output = new BufferedWriter(new FileWriter(testFile1));
    output.write("");
    output.close();
    File testFile2 = new File(baseDir, "testFile2.txt");
    BufferedWriter output2 = new BufferedWriter(new FileWriter(testFile2));
    output2.write("");
    output2.close();
    InputStream fileStream1 = GalenUtils.findFileOrResourceAsStream(testFile1.getAbsolutePath());
    assertThat(fileStream1, notNullValue());
    InputStream fileStream2 = GalenUtils.findFileOrResourceAsStream(
            tempDir.toString() + File.separator + ".." + File.separator + "testFile2.txt");
    assertThat(fileStream2, notNullValue());
    FileUtils.deleteQuietly(tempDir);
    FileUtils.deleteQuietly(testFile2);
}

From source file:de.uni_siegen.wineme.come_in.thumbnailer.thumbnailers.PDFBoxThumbnailer.java

@Override
public void generateThumbnail(final File input, final File output) throws IOException, ThumbnailerException {

    FileUtils.deleteQuietly(output);

    PDDocument document = null;//from w ww. jav a 2  s .com
    try {
        try {
            document = PDDocument.load(input);
        } catch (final IOException e) {
            throw new ThumbnailerException("Could not load PDF File", e);
        }

        final List<?> pages = document.getDocumentCatalog().getAllPages();
        final PDPage page = (PDPage) pages.get(0);
        final BufferedImage tmpImage = this.writeImageForPage(document, page, BufferedImage.TYPE_INT_RGB);

        if (tmpImage.getWidth() == this.thumbWidth) {
            ImageIO.write(tmpImage, PDFBoxThumbnailer.OUTPUT_FORMAT, output);
        } else {
            final ResizeImage resizer = new ResizeImage(this.thumbWidth, this.thumbHeight);
            resizer.resizeMethod = ResizeImage.NO_RESIZE_ONLY_CROP;
            resizer.setInputImage(tmpImage);
            resizer.writeOutput(output);
        }
    }

    finally {
        if (document != null) {
            try {
                document.close();
            } catch (final IOException e) {
            }
        }
    }
}

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

@AfterMethod
public void tearDown() throws IOException {
    tearDownLocalConfig(config);
    FileUtils.deleteQuietly(archiverData);
}

From source file:com.github.blindpirate.gogradle.util.IOUtils.java

public static void deleteQuitely(final File file) {
    FileUtils.deleteQuietly(file);
}

From source file:dkpro.similarity.algorithms.vsm.store.vectorindex.VectorIndexReaderWriterTest.java

private void testVector(Vector aVector) throws Exception {
    File path = new File("target/test");
    FileUtils.deleteQuietly(path);
    path.mkdirs();//from   w ww  .  j a v  a 2  s .  c  o  m

    String term = "DaveApiWebService#DrmRulesGet";

    VectorIndexWriter writer = new VectorIndexWriter(path, aVector.size());
    writer.put(term, aVector);
    writer.close();

    VectorIndexReader reader = new VectorIndexReader(path);
    Vector vo = reader.getVector(term);
    reader.close();

    assertNotNull(vo);

    vo.add(-1, aVector);

    assertEquals(0, vo.norm(Norm.TwoRobust), 0.00001);
}

From source file:com.mirth.connect.util.messagewriter.MessageWriterFactory.java

public MessageWriter getMessageWriter(MessageWriterOptions options, Encryptor encryptor)
        throws MessageWriterException {
    String baseFolder = StringUtils.defaultString(options.getBaseFolder(), System.getProperty("user.dir"));
    String rootFolder = FilenameUtils.getAbsolutePath(new File(baseFolder), options.getRootFolder());
    String filePattern = options.getFilePattern();

    if (filePattern.substring(0, 1).equals(IOUtils.DIR_SEPARATOR)) {
        filePattern = filePattern.substring(1);
    }//from  w  w  w  . j  ava  2  s  .  com

    MessageWriterFile fileWriter = new MessageWriterFile(rootFolder, filePattern, options.getContentType(),
            options.isDestinationContent(), options.isEncrypt(), encryptor);

    if (options.getArchiveFormat() == null) {
        return fileWriter;
    }

    if (options.getArchiveFileName() == null) {
        options.setArchiveFileName(
                new SimpleDateFormat(ARCHIVE_DATE_PATTERN).format(Calendar.getInstance().getTime()));
    }

    /*
     * If we are writing to an archive, make the vfsWriter write to a temporary folder that will
     * be removed once the archive file has been created
     */
    String tempFolder = rootFolder + IOUtils.DIR_SEPARATOR + "." + options.getArchiveFileName();
    FileUtils.deleteQuietly(new File(tempFolder));
    fileWriter.setPath(tempFolder);

    File archiveFile = new File(rootFolder + IOUtils.DIR_SEPARATOR + options.getArchiveFileName() + "."
            + getArchiveExtension(options.getArchiveFormat(), options.getCompressFormat()));

    return new MessageWriterArchive(fileWriter, new File(tempFolder), archiveFile, options.getArchiveFormat(),
            options.getCompressFormat());
}