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.novoda.imageloader.core.file.FileTestCase.java

protected void deleteCacheDir() {
    try {//from   w ww. ja  v  a 2 s.  c  om
        FileUtils.deleteDirectory(cacheDir);
    } catch (Exception e) {
        if (WhatOS.isWindows()) {
            System.err.println("Problem deleting the cachedir : " + e.getMessage());
        } else {
            Assert.fail("Problem deleting the cachedir : " + e.getMessage());
        }
    }
}

From source file:br.uff.ic.archd.javacode.JavaProjectFileService.java

JavaProjectFileService(String projectName) {
    this.projectName = projectName;
    String fileStr = path + projectName;
    try {// ww w. j  a  va2s .  com
        if (new File(fileStr).exists()) {
            FileUtils.deleteDirectory(new File(fileStr));
        }
    } catch (Exception e) {
        System.out.println("");
    }
}

From source file:com.netflix.imfutility.itunes.asset.AudioAssetProcessorTest.java

@BeforeClass
public static void setupAll() throws IOException {
    // create both working directory and logs folder.
    FileUtils.deleteDirectory(TemplateParameterContextCreator.getWorkingDir());
    File workingDir = TemplateParameterContextCreator.getWorkingDir();
    if (!workingDir.mkdir()) {
        throw new RuntimeException("Could not create a working dir within tmp folder");
    }//  w  w w .j  a  va 2 s.  c o  m
}

From source file:com.topekalabs.testutils.FileTestWatcher.java

@Override
public void starting(Description description) {
    String fileName = TestUtils.BUILD_DIR + File.separator + description.getClassName() + File.separator
            + description.getMethodName();

    tempDir = new File(fileName);

    try {//w  w  w.  jav  a 2  s .co  m
        FileUtils.deleteDirectory(tempDir);
    } catch (IOException ex) {
        throw new RuntimeException(ex);
    }

    tempDir.mkdirs();
}

From source file:io.dfox.junit.http.example.NoteRepository.java

public void cleanup() throws IOException {
    FileUtils.deleteDirectory(dir);
}

From source file:GitHelper.java

public static File cloneRepository(String cloneUrl, String repoPw)
        throws GitAPIException, JSONException, IOException {
    config = ConfigParser.getConfig();/*from   w  ww.  j a va2  s.  co  m*/
    File tmpDir = new File("temp_repo");
    String key = null;
    String keyPassPhrase = null;
    if (config.has("privateKey")) {
        key = config.getString("privateKey");
        keyPassPhrase = config.getString("privateKeyPassPhrase");
    }
    // git clone will fail if the directory already exists, even if empty
    if (tmpDir.exists()) {
        FileUtils.deleteDirectory(tmpDir);
    }
    String pw = null;
    if (repoPw != null) {
        pw = repoPw;
    } else if (config.has("gitClonePassword")) {
        pw = config.getString("gitClonePassword");
    }
    final String finalKeyPassPhrase = keyPassPhrase;
    final String finalKey = key;

    SshSessionFactory sessionFactory = new CustomJschConfigSessionFactory();

    // use a private key if provided
    if (finalKey != null) {
        SshSessionFactory.setInstance(sessionFactory);
    }

    // use a password if provided
    if (pw != null) {
        final String finalPw = pw;
        SshSessionFactory.setInstance(new JschConfigSessionFactory() {
            @Override
            protected void configure(OpenSshConfig.Host host, Session session) {
                session.setPassword(finalPw);
            }
        });
    }
    SshSessionFactory.setInstance(sessionFactory);
    Git.cloneRepository().setURI(cloneUrl).setDirectory(tmpDir)
            .setTransportConfigCallback(new TransportConfigCallback() {
                @Override
                public void configure(Transport transport) {
                    SshTransport sshTransport = (SshTransport) transport;
                    sshTransport.setSshSessionFactory(sessionFactory);
                }
            }).call();

    return tmpDir;
}

From source file:controller.DeleteTextControllerTest.java

@AfterClass
public static void tearDownClass() {

    String home = System.getProperty("user.dir") + File.separator + "MyDiaryBook";
    File path = new File(home);
    try {//from  w w  w. j av a  2 s . c  o m
        FileUtils.deleteDirectory(path);
    } catch (IOException ex) {
        //         Logger.getLogger(DeleteControllerTest.class.getName()).log(Level.SEVERE, null, ex);
    }
}

From source file:hu.petabyte.redflags.engine.test.NoticeCacheTest.java

@BeforeClass
@AfterClass// w  ww.  j av  a2  s .c om
public static void cleanup() {
    try {
        FileUtils.deleteDirectory(new File(directory));
    } catch (IOException e) {
        e.printStackTrace();
    }
}

From source file:com.mammothdata.apex.example.ApplicationTest.java

@Before
public void beforeTest() throws Exception {
    kafkaLauncher.baseDir = "target/" + this.getClass().getName();
    FileUtils.deleteDirectory(new File(kafkaLauncher.baseDir));
    kafkaLauncher.startZookeeper();//from   w  w w .  ja v a 2s .c o m
    kafkaLauncher.startKafkaServer();
    kafkaLauncher.createTopic(0, TOPIC);
}

From source file:controller.DeleteImageControllerTest.java

@AfterClass
public static void tearDownClass() {
    String home = System.getProperty("user.dir") + File.separator + "MyDiaryBook";
    File path = new File(home);
    try {//  w w w.  ja  v a 2 s . c om
        FileUtils.deleteDirectory(path);
    } catch (IOException ex) {
        //         Logger.getLogger(DeleteControllerTest.class.getName()).log(Level.SEVERE, null, ex);
    }
}