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

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

Introduction

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

Prototype

public static void deleteDirectory(File directory) throws IOException 

Source Link

Document

Deletes a directory recursively.

Usage

From source file:name.martingeisse.common.util.TemporaryFolder.java

/**
 * Initializes the temporary folder system for the specified application.
 * The application identifier is used as the name of the subfolder inside
 * /var/projects/temp./*from w  ww  . j  a  va  2s  . com*/
 * @param applicationIdentifier the application-specific identifier / folder name
 */
public static synchronized void initialize(String applicationIdentifier) {
    applicationFolder = new File("/var/projects/temp/" + applicationIdentifier);
    try {
        FileUtils.deleteDirectory(applicationFolder);
    } catch (IOException e) {
        throw new RuntimeException(
                "cannot delete previous temporary application folder: " + applicationFolder.getAbsolutePath());
    }
    if (!applicationFolder.mkdir()) {
        throw new RuntimeException(
                "cannot create temporary application folder: " + applicationFolder.getAbsolutePath());
    }
}

From source file:com.twitter.distributedlog.ZooKeeperClusterTestCase.java

@AfterClass
public static void shutdownZooKeeper() throws Exception {
    zks.stop();/*from  w ww . jav a2 s.c  o m*/
    if (null != zkDir) {
        FileUtils.deleteDirectory(zkDir);
    }
}

From source file:com.xiaomi.linden.hadoop.indexing.LindenMapredTest.java

@AfterClass
public static void destroy() throws IOException {
    FileUtils.deleteDirectory(new File(indexPath));
}

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 {/* w ww.j a  v  a  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:net.sf.jdbcwrappers.spring.SpringTest.java

@AfterClass
public static void destroyDataSource() throws Exception {
    dataSource.setShutdownDatabase("shutdown");
    try {// w  ww  . j a va  2s.  co m
        dataSource.getConnection();
    } catch (SQLException ex) {
        // This always throws an exception; just continue
    }
    FileUtils.deleteDirectory(new File("target/testDB"));
}

From source file:controller.NewEntryDeleteControllerTest.java

@AfterClass
public static void tearDownClass() {
    File file = new File(System.getProperty("user.dir") + fSeparator + "MyDiaryBook");
    try {//from   w w w  . j  a  v  a2s  .c o  m
        FileUtils.deleteDirectory(file);
    } catch (IOException ex) {
        Logger.getLogger(NewEntryDeleteControllerTest.class.getName()).log(Level.SEVERE, null, ex);
    }
}

From source file:IO.Directories.java

/**
 * Delete directory// w w  w. j a  va  2  s. c  o m
 *
 * @param directoryPath path of the destination directory to delete
 * @return true if the directory was deleted
 */
public static boolean DeleteDirectory(String directoryPath) {
    boolean deleted = false;
    try {
        if (Directories.IsDirectory(directoryPath)) {
            FileUtils.deleteDirectory(new File(directoryPath));
            deleted = true;
        }
    } catch (IOException e) {
        Console.PrintException(String.format("Error deleting directory: %s", directoryPath), e);
    }
    return deleted;
}

From source file:com.playonlinux.core.utils.Files.java

/**
 * Delete a file only if it is inside PlayOnLinux root
 * @param fileToDelete fileOrDirectoryToDelete
 */// ww  w.  j  av a2  s  .c  o  m
public static void remove(File fileToDelete) throws IOException {
    final File userRoot = playOnLinuxContext.makeUserRootPath();

    if (!isInSubDirectory(userRoot, fileToDelete)) {
        throw new IllegalArgumentException(format(
                "The file (%s) must be in a the PlayOnLinux root directory (%s)", fileToDelete, userRoot));
    }

    FileUtils.deleteDirectory(fileToDelete);
}

From source file:com.gs.obevo.db.apps.reveng.AseDdlgenRevengTest.java

@Test
public void testInstructions() throws Exception {
    File outputDir = new File("./target/ddlgen/instructions");
    FileUtils.deleteDirectory(outputDir);

    AquaRevengArgs args = new AquaRevengArgs();
    args.setDbSchema("dbdeploy01");
    args.setGenerateBaseline(false);//  w  w  w . j av a  2 s  .  c  o m
    args.setOutputPath(outputDir);

    new AseDdlgenReveng().reveng(args);
}

From source file:eu.scape_project.arc2warc.RecordMigratorTest.java

@AfterClass
public static void tearDownClass() throws IOException {
    FileUtils.deleteDirectory(tempDir);
}