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:com.github.ipaas.ideploy.plugin.core.ChineseFileNameFilter.java

public static void deleteChineseNameFile(String prePath, File rootFile) {
    if (CharUtil.isChinese(rootFile.getName())) {
        try {//from w w w  .  j a va 2 s  .c  o  m
            if (rootFile.isDirectory()) {
                ConsoleHandler.error("??:"
                        + StringUtils.removePrefix(rootFile.getAbsolutePath().replaceAll("\\\\", "/"), prePath)
                        + "  ?");
                FileUtils.deleteDirectory(rootFile);
            } else {
                ConsoleHandler.error("??:"
                        + StringUtils.removePrefix(rootFile.getAbsolutePath().replaceAll("\\\\", "/"), prePath)
                        + "  ?");
                FileUtils.forceDelete(rootFile);
            }
        } catch (IOException e) {
            ConsoleHandler.error(":" + e.getMessage());
        }
    }
    if (rootFile.isDirectory()) {
        File[] files = rootFile.listFiles();
        for (int i = 0; i < files.length; i++) {
            System.out.println(files[i].getAbsolutePath());
            deleteChineseNameFile(prePath, files[i]); // ?
        }
    }
}

From source file:io.proscript.jlight.CacheManager.java

public void destroy() throws IOException {
    FileUtils.forceDelete(this.environment.getCacheDirectory());
}

From source file:com.ariht.maven.plugins.config.io.DirectoryDeleter.java

/**
 * Clear contents of config generation build target/output io ready for new directory.
 *///from www  .  j av  a 2  s.  co m
public void clearTargetDirectory(final String outputBasePath, final Log logger) throws MojoFailureException {
    final File outputDir = new File(outputBasePath);
    if (outputDir.exists()) {
        logger.debug("Deleting : " + outputDir);
        try {
            FileUtils.forceDelete(outputDir);
        } catch (IOException e) {
            logger.error("Error while clearing config generation output io: [" + outputDir + "], error was: "
                    + String.valueOf(e.getMessage()));
            throw new MojoFailureException(e.getMessage(), e);
        }
    }
}

From source file:net.ontopia.infoset.content.FileContentStoreTest.java

@Override
public void setUp() throws IOException, ContentStoreException {
    File tstdir = getTestDirectory("content");

    if (tstdir.exists()) {
        File[] files = tstdir.listFiles();
        for (int ix = 0; ix < files.length; ix++)
            FileUtils.forceDelete(files[ix]);
    } else//  w  ww.j  a  v a  2  s.co m
        tstdir.mkdir();

    store = new FileContentStore(tstdir);
}

From source file:gov.nih.nci.sdk.example.generator.CXFSpringConfGenerator.java

protected void preProcess() {
    try {/*www . j a va  2  s  .co m*/
        File targetBase = new File(getScriptContext().getTargetBase());
        File generatedArtifactsDirectory = new File(targetBase.getAbsolutePath() + GENERATOR_TARGET_PATH);

        if (generatedArtifactsDirectory.exists() == true) {
            FileUtils.forceDelete(generatedArtifactsDirectory);
        }
    } catch (Throwable t) {
        getScriptContext().getErrorManager().add("sdkExample", "severe", t.getMessage());
        getScriptContext().abort();
        t.printStackTrace();
    }
}

From source file:com.kegare.caveworld.client.config.VeinsEntry.java

@Override
public void setToDefault() {
    try {//  www .j av  a2 s .com
        FileUtils.forceDelete(new File(Config.veinsCfg.toString()));
    } catch (IOException e) {
        e.printStackTrace();

        return;
    }

    CaveworldAPI.clearCaveVeins();

    Config.veinsCfg = null;
    Config.syncVeinsCfg();

    if (childScreen instanceof GuiVeinsEntry) {
        GuiVeinsEntry gui = (GuiVeinsEntry) childScreen;

        if (gui.veinList != null) {
            gui.veinList.veins.clear();
            gui.veinList.veins.addAll(CaveworldAPI.getCaveVeins());
            gui.veinList.contents.clear();
            gui.veinList.contents.addAll(gui.veinList.veins);
        }
    }
}

From source file:com.kegare.caveworld.client.config.BiomesEntry.java

@Override
public void setToDefault() {
    try {//from www.ja  v a 2s .c  om
        FileUtils.forceDelete(new File(Config.biomesCfg.toString()));
    } catch (IOException e) {
        e.printStackTrace();

        return;
    }

    CaveworldAPI.clearCaveBiomes();

    Config.biomesCfg = null;
    Config.syncBiomesCfg();

    if (childScreen instanceof GuiBiomesEntry) {
        GuiBiomesEntry gui = (GuiBiomesEntry) childScreen;

        if (gui.biomeList != null) {
            gui.biomeList.biomes.clear();
            gui.biomeList.biomes.addAll(CaveworldAPI.getCaveBiomes());
            gui.biomeList.contents.clear();
            gui.biomeList.contents.addAll(gui.biomeList.biomes);
        }
    }
}

From source file:com.asakusafw.lang.compiler.testdriver.adapter.CompilerToolkitAdapter.java

private static void initializeWorkingDirectory(CompilerConfiguration conf) throws IOException {
    File workingDirectory = conf.getWorkingDirectory();
    if (workingDirectory == null) {
        throw new IllegalStateException();
    }//from   www  . j  a  v a 2s.c o  m
    if (workingDirectory.exists()) {
        FileUtils.forceDelete(workingDirectory);
    }
}

From source file:net.sf.nutchcontentexporter.WARCReaderTest.java

/**
 * Reads bz2 warc file/* ww  w .j a va 2  s. c o m*/
 *
 * @param file warc file
 * @throws IOException
 */
public static void readBz2(String file) throws IOException {
    // decompress bz2 file to tmp file
    File tmpFile = File.createTempFile("tmp", ".warc");
    BZip2CompressorInputStream inputStream = new BZip2CompressorInputStream(new FileInputStream(file));

    IOUtils.copy(inputStream, new FileOutputStream(tmpFile));

    WARCReader reader = WARCReaderFactory.get(tmpFile);

    int counter = 0;
    for (ArchiveRecord record : reader) {
        System.out.println(record.getHeader().getHeaderFields());

        counter++;
    }

    FileUtils.forceDelete(tmpFile);

    System.out.println(counter);
}

From source file:jmassivesort.algs.chunks.BaseChunkReaderTest.java

protected File createTmpFile(String dir, String name) throws IOException {
    File out = new File(dir + "/" + name);
    if (out.exists())
        FileUtils.forceDelete(out);
    FileUtils.touch(out);/*from  w ww  .jav a2 s .com*/

    return out;
}