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:net.mindengine.blogix.tests.acceptance.CompilerAccTest.java

@AfterClass
public void afterClass() throws Exception {
    if (compilerOutputDir.exists()) {
        FileUtils.forceDelete(compilerOutputDir);
    }
}

From source file:com.docd.purefm.test.PFMFileUtilsTest.java

@Override
protected void setUp() throws Exception {
    super.setUp();
    final String state = Environment.getExternalStorageState();
    if (!state.equals(Environment.MEDIA_MOUNTED)) {
        throw new RuntimeException(
                "Make sure the external storage is mounted read-write before running this test");
    }/*  w  ww.  ja va  2s  .c om*/
    try {
        FileUtils.forceDelete(testDir);
    } catch (IOException e) {
        //ignored
    }
    assertTrue(testDir.mkdirs());
}

From source file:com.vmware.photon.controller.model.helpers.BaseModelTest.java

@AfterClass
public void tearDownClass() throws Throwable {
    if (host != null) {
        host.stop();//  w  ww  . ja v  a 2s.  co m
        host = null;
    }
    File sandbox = new File(sandboxDirectory.toUri());
    if (sandbox.exists()) {
        try {
            FileUtils.forceDelete(sandbox);
        } catch (FileNotFoundException | IllegalArgumentException ex) {
            logger.debug("Sandbox file was not found");
        } catch (IOException ex) {
            FileUtils.forceDeleteOnExit(sandbox);
        }
    }
}

From source file:klapersuite.prismanalysis.linux.PrismRunner.java

public boolean uninstall() {
    if (prismInstallationDir().exists())
        try {//from   w w  w  .j av  a  2s.  c om
            FileUtils.forceDelete(prismInstallationDir());
        } catch (IOException e) {
            return false;
        }
    return true;
}

From source file:me.ryandowling.allmightybot.commands.HighlightCommand.java

@Override
public void load() {
    super.save();

    if (Files.exists(Utils.getCommandDataFile(this))) {
        try {/*w  w  w.  ja  v  a  2  s  .co m*/
            FileUtils.forceDelete(Utils.getCommandDataFile(this).toFile());
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}

From source file:com.nokia.helium.metadata.tests.TestORMFMPPLoader.java

/**
 * Populates the LogFile table with basic data.
 * @throws MetadataException/*from   ww w  .  java  2 s. c  o m*/
 * @throws IOException
 */
@Before
public void populateDatabase() throws MetadataException, IOException {
    File tempdir = new File(System.getProperty("test.temp.dir"));
    tempdir.mkdirs();
    database = new File(tempdir, "test_db");
    if (database.exists()) {
        FileUtils.forceDelete(database);
    }
    EntityManagerFactory factory = FactoryManager.getFactoryManager().getEntityManagerFactory(database);
    EntityManager em = factory.createEntityManager();
    try {
        em.getTransaction().begin();
        for (int i = 0; i < 2000; i++) {
            LogFile lf = new LogFile();
            lf.setPath("log" + String.format("%04d", i));
            em.persist(lf);
        }
    } finally {
        if (em.getTransaction().isActive()) {
            em.getTransaction().commit();
        }
        em.close();
        factory.close();
    }
}

From source file:com.github.brandtg.switchboard.TestFileLogServer.java

@BeforeClass
public void beforeClass() throws Exception {
    httpClient = HttpClients.createDefault();
    pollMillis = 1000;/*  w ww  .j  ava2 s . com*/
    timeoutMillis = 30000;
    rootDir = new File(System.getProperty("java.io.tmpdir"), TestFileLogServer.class.getSimpleName());
    testFile = new File(rootDir, "" + System.currentTimeMillis());
    serverAddress = new HttpHost("localhost", 8080);

    if (rootDir.exists()) {
        FileUtils.forceDelete(rootDir);
    }

    FileLogServerConfig config = new FileLogServerConfig();
    config.setRootDir(rootDir.getAbsolutePath());

    server = DropWizardApplicationRunner.createServer(config, FileLogServer.class);
    server.start();
}

From source file:com.github.neoio.nio.impl.FileChannelIOStaging.java

@Override
public void close() throws IOException {
    logger.debug("Closing and deleting staging file: {}", file.getPath());
    channel.close();//from  ww w .ja  va  2s.co m
    FileUtils.forceDelete(file);
}

From source file:com.splunk.shuttl.archiver.bucketlock.SimpleFileLockSharedTest.java

@AfterMethod
public void tearDown() throws IOException {
    otherJvmLocker.kill();
    FileUtils.forceDelete(FILE_TO_LOCK);
}

From source file:de.tudarmstadt.ukp.dkpro.discourse.pdtbparser.PDTBParserWrapper.java

public PDTBParserWrapper() throws IOException {
    tempDirectory = Files.createTempDirectory("temp_pdtb");

    //        FileUtils.copyFileToDirectory();
    File tempDir = tempDirectory.toFile();

    File tmpFile = File.createTempFile("tmp_pdtb", ".zip");

    InputStream stream = getClass().getClassLoader().getResourceAsStream("pdtb-parser-v120415.zip");
    FileUtils.copyInputStreamToFile(stream, tmpFile);

    ZipFile zipFile;/*from  w ww  . ja  v a 2s.  com*/
    try {
        zipFile = new ZipFile(tmpFile);
        zipFile.extractAll(tempDir.getAbsolutePath());
    } catch (ZipException e) {
        throw new IOException(e);
    }

    // delete temp file
    FileUtils.forceDelete(tmpFile);

    String folderPrefix = "/pdtb-parser-v120415/src";
    String srcDir = tempDir.getCanonicalPath() + folderPrefix;

    // copy rewritten rb files
    copyFiles(new File(srcDir), "article.rb", "parser.rb");

    Files.walkFileTree(tempDirectory, new SimpleFileVisitor<Path>() {
        @Override
        public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) throws IOException {
            Set<PosixFilePermission> permissions = new HashSet<>();
            permissions.add(PosixFilePermission.OWNER_EXECUTE);
            permissions.add(PosixFilePermission.GROUP_EXECUTE);
            permissions.add(PosixFilePermission.OTHERS_EXECUTE);
            permissions.add(PosixFilePermission.OWNER_READ);
            permissions.add(PosixFilePermission.GROUP_READ);
            permissions.add(PosixFilePermission.OTHERS_READ);

            Files.setPosixFilePermissions(file, permissions);

            return super.visitFile(file, attrs);
        }
    });

    parserRubyScript = srcDir + "/parser.rb";

    System.out.println(parserRubyScript);
}