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:com.walmart.gatling.commons.MasterTest.java

@BeforeClass
public static void setupActorSystem() throws Exception {

    FileUtils.deleteDirectory(new File("journal"));
    FileUtils.deleteDirectory(new File("shared-journal"));
    FileUtils.deleteDirectory(new File("snapshots"));
    //file.isDirectory()
    agentConfig = new AgentConfig();
    AgentConfig.LogServer log = new AgentConfig.LogServer();
    log.setHostName("127.0.0.1");
    log.setPort(8080);/*from  w  w  w. j  a  va2  s . co m*/
    agentConfig.setLogServer(log);
    system = startMaster();
    final Props props = Master.props(new FiniteDuration(20, TimeUnit.SECONDS), agentConfig);
    master = system.actorOf(props, "master");
}

From source file:com.theminequest.MineQuest.Quest.QuestWorldManip.java

public static void removeWorld(World w) throws IOException {
    String removename = w.getName();
    if (Bukkit.unloadWorld(w, false))
        FileUtils.deleteDirectory(new File(removename));
}

From source file:com.gargoylesoftware.htmlunit.source.SVN.java

/**
 * Recursively deletes any '.svn' folder which contains Subversion information.
 * @param dir the directory to recursively delete '.svn' from
 * @throws IOException if an exception happens
 *//*  w w w . j ava  2s .c o m*/
public static void deleteSVN(final File dir) throws IOException {
    for (final File f : dir.listFiles()) {
        if (f.isDirectory()) {
            if (".svn".equals(f.getName())) {
                FileUtils.deleteDirectory(f);
            } else {
                deleteSVN(f);
            }
        }
    }
}

From source file:com.cisco.cta.taxii.adapter.ConfigTaskTest.java

@Test
public void createsConfigDir() throws Exception {
    Path configDir = Paths.get("target/config");
    FileUtils.deleteDirectory(configDir.toFile());
    ConfigTask cfTask = new ConfigTask(configDir.toString());
    cfTask.run();/*  w w  w  .j ava2  s .c o  m*/

    assertTrue(Files.exists(configDir));
    assertTrue(Files.exists(Paths.get(configDir.toString(), "application.yml")));
    assertTrue(Files.exists(Paths.get(configDir.toString(), "logback.xml")));
    assertTrue(Files.exists(Paths.get(configDir.toString(), "stix2cef.xsl")));
    assertTrue(Files.exists(Paths.get(configDir.toString(), "stix2splunk.xsl")));
    assertTrue(Files.exists(Paths.get(configDir.toString(), "stix2stix.xsl")));
    assertTrue(Files.exists(Paths.get(configDir.toString(), "taxii-response.xsl")));

}

From source file:myproject.Model.Message.CommonMessages.DeleteDirectoryMessage.java

@Override
public void executeMessage(AbstractClient client) throws Throwable {
    try {//from  w  w w  .ja va2s . c o  m
        FileUtils.deleteDirectory(node.getValue());
        Object[][] args = new Object[][] { { node } };
        AbstractMessage message = new FillDeletedFilesInfoMessage(args);
        client.sendMessage(message);
    } catch (IOException e) {
        Object[][] args = new Object[][] { { e.getMessage(), e.getCause() } };
        AbstractMessage message = new ExceptionMessage("DeleteDirectoryMessage", args);
        client.sendMessage(message);
    }
}

From source file:citibob.licensor.MakeLauncher.java

/**
 * //from  ww  w  .jav a2  s.c o  m
 * @param version
 * @param configDir
 * @param outJar
 * @param spassword
 * @throws java.lang.Exception
 */
public static void makeLauncher(String version, File configDir, File outJar, String spassword)
        throws Exception {
    File oaDir = ClassPathUtils.getMavenProjectRoot();
    File oalaunchDir = new File(oaDir, "../oalaunch");
    File oasslDir = new File(oaDir, "../oassl");
    File keyDir = new File(oasslDir, "keys/client");
    File tmpDir = new File(".", "tmp");
    FileUtils.deleteDirectory(tmpDir);
    tmpDir.mkdirs();

    // Find the oalaunch JAR file
    File oalaunchJar = null;
    File[] files = new File(oalaunchDir, "target").listFiles();
    for (File f : files) {
        if (f.getName().startsWith("oalaunch") && f.getName().endsWith(".jar")) {
            oalaunchJar = f;
            break;
        }
    }

    // Unjar the oalaunch.jar file into the temporary directory
    exec(tmpDir, "jar", "xvf", oalaunchJar.getAbsolutePath());

    File tmpOalaunchDir = new File(tmpDir, "oalaunch");
    File tmpConfigDir = new File(tmpOalaunchDir, "config");

    // Read app.properties
    Properties props = new Properties();
    InputStream in = new FileInputStream(new File(configDir, "app.properties"));
    props.load(in);
    in.close();

    // Re-do the config dir
    FileUtils.deleteDirectory(tmpConfigDir);
    FileFilter ff = new FileFilter() {
        public boolean accept(File f) {
            if (f.getName().startsWith("."))
                return false;
            if (f.getName().endsWith("~"))
                return false;
            return true;
        }
    };
    FileUtils.copyDirectory(configDir, tmpConfigDir, ff);

    // Set up to encrypt
    char[] password = null;
    PBECrypt pbe = new PBECrypt();
    if (spassword != null)
        password = spassword.toCharArray();

    // Encrypt .properties files if needed
    if (password != null) {
        for (File fin : configDir.listFiles()) {
            if (fin.getName().endsWith(".properties") || fin.getName().endsWith(".jks")) {
                File fout = new File(tmpConfigDir, fin.getName());
                pbe.encrypt(fin, fout, password);
            }
        }
    }

    // Copy the appropriate key and certificate files
    String dbUserName = props.getProperty("db.user", null);
    File[] jksFiles = new File[] { new File(keyDir, dbUserName + "-store.jks"),
            new File(keyDir, dbUserName + "-trust.jks") };
    for (File fin : jksFiles) {
        if (!fin.exists()) {
            System.out.println("Missing jks file: " + fin.getName());
            continue;
        }
        File fout = new File(tmpConfigDir, fin.getName());
        if (password != null) {
            System.out.println("Encrypting " + fin.getName());
            pbe.encrypt(fin, fout, password);
        } else {
            System.out.println("Copying " + fin.getName());
            FileUtils.copyFile(fin, fout);
        }
    }

    // Use a downloaded JNLP file, not a static one.
    new File(tmpOalaunchDir, "offstagearts.jnlp").delete();

    // Open properties file, which we will write to...
    File oalaunchProperties = new File(tmpDir, "oalaunch/oalaunch.properties");
    Writer propertiesOut = new FileWriter(oalaunchProperties);
    propertiesOut.write(
            "jnlp.template.url = " + "http://offstagearts.org/releases/offstagearts/offstagearts_oalaunch-"
                    + version + ".jnlp.template\n");
    String configName = outJar.getName();
    int dot = configName.lastIndexOf(".jar");
    if (dot >= 0)
        configName = configName.substring(0, dot);
    propertiesOut.write("config.name = " + configName + "\n");
    propertiesOut.close();

    // Jar it back up
    exec(tmpDir, "jar", "cvfm", outJar.getAbsolutePath(), "META-INF/MANIFEST.MF", ".");

    //   // Sign it
    //   exec(null, "jarsigner", "-storepass", "keyst0re", outJar.getAbsolutePath(),
    //         "offstagearts");

    // Remove the tmp directory
    FileUtils.deleteDirectory(tmpDir);
}

From source file:com.fizzed.blaze.kotlin.BlazeKotlinEngineTest.java

@BeforeClass
static public void clearCache() throws IOException {
    Context context = new ContextImpl(null, Paths.get(System.getProperty("user.home")), null, null);
    Path classesDir = ConfigHelper.userBlazeEngineDir(context, "kotlin");
    FileUtils.deleteDirectory(classesDir.toFile());
}

From source file:io.datalayer.lucene.helper.AosLuceneUtil.java

public static File createIndexFile(String indexPath) {
    File indexFile = new File(indexPath);
    try {//from  w  w w  .  j a v  a  2  s.  co  m
        FileUtils.deleteDirectory(indexFile);
    } catch (IOException e) {
        throw new RuntimeException(e);
    }
    return indexFile;
}

From source file:mapred.BigDiffHadoopTest.java

@Before
public void setUp() throws IOException {
    // get rid of previous results, to avoid FileAlreadyExistsException
    FileUtils.deleteDirectory(new File(outputDirectory));
}

From source file:com.qait.automation.samjbehavedemo.utils.FileHandler.java

public static void cleanStoryLocation() {
    File storiesDir = getFile(Constants.STORY_LOC);
    if (storiesDir.exists()) {
        try {/*from  w ww  . jav a  2 s. c  om*/
            FileUtils.deleteDirectory(storiesDir);

        } catch (IOException ex) {
            Logger.getLogger(JiraStoryDownloader.class.getName()).log(Level.SEVERE,
                    "UNABLE TO DELETE OLD STORIES", ex);
            ex.printStackTrace();
        }
    }
    storiesDir.mkdir();
}