Example usage for org.apache.commons.io FileUtils forceDelete

List of usage examples for org.apache.commons.io FileUtils forceDelete

Introduction

In this page you can find the example usage for org.apache.commons.io FileUtils forceDelete.

Prototype

public static void forceDelete(File file) throws IOException 

Source Link

Document

Deletes a file.

Usage

From source file:fr.inria.atlanmod.neoemf.tests.AllBackendTest.java

@After
public void tearDown() throws Exception {
    PersistentResourceImpl.shutdownWithoutUnload((PersistentResourceImpl) mapResource);
    PersistentResourceImpl.shutdownWithoutUnload((PersistentResourceImpl) neo4jResource);
    PersistentResourceImpl.shutdownWithoutUnload((PersistentResourceImpl) tinkerResource);

    if (mapFile.exists()) {
        FileUtils.forceDelete(mapFile);
    }/*from  ww  w .jav a2  s . c o  m*/
    if (neo4jFile.exists()) {
        FileUtils.forceDelete(neo4jFile);
    }
    if (tinkerFile.exists()) {
        FileUtils.forceDelete(tinkerFile);
    }
}

From source file:com.moneydance.modules.features.importlist.io.DeleteOneOperation.java

@Override
public void execute(final List<File> files) {
    final File file = files.iterator().next();
    // ESCA-JAVA0166: IOException, SecurityException
    try {//w ww. j  a  v a  2 s.  com
        LOG.info(String.format("Deleting file %s", file.getAbsoluteFile()));
        FileUtils.forceDelete(file);
    } catch (Exception e) { // $codepro.audit.disable caughtExceptions
        LOG.log(Level.WARNING, e.getMessage(), e);
        final String errorMessage = this.localizable.getErrorMessageDeleteFile(file.getName());
        final Object errorLabel = new JLabel(errorMessage);
        JOptionPane.showMessageDialog(null, // no parent component
                errorLabel, null, // no title
                JOptionPane.ERROR_MESSAGE);
    }
}

From source file:com.ss.language.model.gibblda.Dictionary.java

public void init(LDACmdOption option) {
    ids = new File(option.dir, "word-ids.txt");
    try {//from  w ww  .  java 2 s . c  om
        if (ids.isFile()) {
            FileUtils.forceDelete(ids);
        }
        ids.createNewFile();
    } catch (IOException e) {
    }
}

From source file:fr.inria.atlanmod.neoemf.graph.blueprints.datastore.BlueprintsPersistenceBackendFactoryTest.java

@After
public void tearDown() {
    PersistenceBackendFactoryRegistry.getFactories().clear();
    if (testFile != null) {
        try {/*from  ww w .  ja  va2 s.  com*/
            FileUtils.forceDelete(testFile);
        } catch (IOException e) {

        }
        testFile = null;
    }
}

From source file:edu.usc.irds.agepredictor.spark.authorage.AgePredictSGDTrainer.java

public static void generateEvents(SparkSession spark, String dataIn, String tokenizer, String featureGenerators,
        String outDir) throws IOException {

    AgeClassifyContextGeneratorWrapper wrapper = new AgeClassifyContextGeneratorWrapper(tokenizer,
            featureGenerators);/*w w w .  ja  v  a2s  . com*/

    JavaRDD<String> data = spark.sparkContext().textFile(dataIn, 48).toJavaRDD().cache();

    JavaRDD<EventWrapper> samples = data.map(new CreateEvents(wrapper)).cache();

    JavaRDD<EventWrapper> validSamples = samples.filter(new Function<EventWrapper, Boolean>() {
        @Override
        public Boolean call(EventWrapper s) {
            if (s != null) {
                return s.getValue() != null;
            }
            return false;
        }
    }).repartition(8);

    File dir = new File(outDir);
    if (dir.exists()) {
        FileUtils.cleanDirectory(dir); //clean out directory (this is optional -- but good know)
        FileUtils.forceDelete(dir); //delete directory
    }

    validSamples.saveAsTextFile(outDir);
}

From source file:com.cognitivabrasil.repositorio.services.DocumentServiceImpl.java

@Override
public void delete(Document d) throws IOException {

    try {/* www .j  a v a 2 s.co  m*/
        FileUtils.forceDelete(new File(Config.FILE_PATH + d.getId()));
    } catch (IOException io) {
        LOG.warn("Nao foi possivel deletar os arquivos do documento: " + d.getId() + "."
                + "Mas o documento sera removido da base! " + io.getMessage());
        throw io;
    } finally {
        d.getFiles().clear();
        d.setObaaXml(null);
        d.setCreated(new DateTime());
        d.setDeleted(true);
        docRep.save(d);
    }

}

From source file:com.asakusafw.testdriver.compiler.util.DeploymentUtil.java

/**
 * Deletes the target file/directory./*from   w w  w  . jav  a  2s.c  o m*/
 * @param target the target file/directory
 * @param options the operation options
 * @return {@code true} if the target file/directory was successfully deleted (or does not exist initially),
 *     otherwise {@code false}
 * @throws IOException if I/O error was occurred
 */
public static boolean delete(File target, DeleteOption... options) throws IOException {
    if (target.exists() == false) {
        return true;
    }
    Set<DeleteOption> opts = EnumSet.noneOf(DeleteOption.class);
    Collections.addAll(opts, options);
    if (opts.contains(DeleteOption.QUIET)) {
        return FileUtils.deleteQuietly(target);
    } else {
        FileUtils.forceDelete(target);
        return true;
    }
}

From source file:de.tudarmstadt.ukp.dkpro.core.api.resources.RuntimeProvider.java

public File getWorkspace() throws IOException {
    if (workspace == null) {
        workspace = File.createTempFile("dkpro", "runtime");
        FileUtils.forceDelete(workspace);
        FileUtils.forceMkdir(workspace);
        workspace.deleteOnExit();/*from w  ww .ja v  a2s .  c o m*/
    }
    return workspace;
}

From source file:de.saly.elasticsearch.importer.imap.IMAPImporterCl.java

public static void start(Map<String, Object> settings, boolean embeddedMode) throws Exception {

    Settings.Builder builder = Settings.settingsBuilder();

    for (String key : settings.keySet()) {
        builder.put(key, String.valueOf(settings.get(key)));
    }/*from   www .  j  a  va  2s.c  om*/

    if (embeddedMode) {
        try {
            FileUtils.forceDelete(new File("./data"));
        } catch (Exception e) {
            //ignore
        }
        builder.put("path.home", ".");
        builder.put("node.local", true);
        builder.put("http.cors.enabled", true);
        builder.put("http.cors.allow-origin", "*");
        builder.put("cluster.name", "imap-embedded-" + System.currentTimeMillis());
        node = new PluginAwareNode(builder.build(),
                (Collection) Lists.newArrayList(MapperAttachmentsPlugin.class));
        node.start();
        client = node.client();
    } else {
        Settings eSettings = builder.build();
        client = new TransportClient.Builder().settings(eSettings).build();
        String[] hosts = eSettings.get("elasticsearch.hosts").split(",");

        for (int i = 0; i < hosts.length; i++) {
            String host = hosts[i];
            String hostOnly = host.split(":")[0];
            String portOnly = host.split(":")[1];
            System.out.println("Adding " + hostOnly + ":" + portOnly);
            ((TransportClient) client).addTransportAddress(new InetSocketTransportAddress(
                    InetAddress.getByName(hostOnly), Integer.parseInt(portOnly)));
        }
    }
    imap = new IMAPImporter(settings, client);
    imap.start();
}

From source file:com.google.gct.idea.appengine.synchronization.SampleSyncTaskTest.java

@Override
public void tearDown() throws IOException {
    FileUtils.forceDelete(new File(mockAndroidRepoPath));
}