List of usage examples for org.apache.commons.io FileUtils deleteDirectory
public static void deleteDirectory(File directory) throws IOException
From source file:io.stallion.tests.integration.javaPlugin.JavaPluginTest.java
@AfterClass public static void tearDownClass() throws Exception { // Delete the existing folders File timingRecordFolder = new File(Context.settings().getTargetFolder() + "/timeit/timing-records"); if (timingRecordFolder.exists()) { FileUtils.deleteDirectory(timingRecordFolder); }/*www . j a va 2 s.c om*/ File journalFolder = new File(Context.settings().getTargetFolder() + "/timeit/journal-entries"); if (journalFolder.exists()) { FileUtils.deleteDirectory(journalFolder); } cleanUpClass(); }
From source file:com.abiquo.testng.AMRepositoryListener.java
public static void resetRepo() { File vmrepo = new File(REPO_PATH); try {/* w w w . j ava 2 s .c o m*/ if (vmrepo.exists()) { FileUtils.deleteDirectory(vmrepo); } vmrepo.mkdirs(); new File(REPO_PATH + ".abiquo_repository").createNewFile(); } catch (Exception e) { throw new RuntimeException("Can't init test repository filesystem", e); } LOGGER.info("Created AM repository"); }
From source file:com.github.drbookings.DrBookingsApplicationUITest.java
@AfterClass public static void tearDownClass() throws Exception { FileUtils.deleteDirectory(USER_HOME); }
From source file:com.na.install.JerseyWizardTest.java
@BeforeClass public static void beforeClass() throws IOException { File f = new File("WEB-INF"); if (!f.exists()) { f.mkdir();//from ww w. j a v a 2 s . c o m f = new File("WEB-INF/classes"); f.mkdir(); return; } f = new File("WEB-INF/classes/META-INF"); if (f.exists()) { FileUtils.deleteDirectory(f); } }
From source file:com.enonic.cms.framework.blob.file.FileBlobStoreTest.java
@After public void tearDown() throws Exception { FileUtils.deleteDirectory(this.tmpDir); }
From source file:controller.NewEntryImageControllerTest.java
@AfterClass public static void tearDownClass() { File file = new File(System.getProperty("user.dir") + fSeparator + "MyDiaryBook"); try {//from ww w.j a v a2s .c o m FileUtils.deleteDirectory(file); } catch (IOException ex) { Logger.getLogger(NewEntryImageControllerTest.class.getName()).log(Level.SEVERE, null, ex); } }
From source file:com.github.tomakehurst.wiremock.SavingMappingsAcceptanceTest.java
private static void resetFileSourceRoot() { try {/*from ww w .j ava 2s .co m*/ if (FILE_SOURCE_ROOT.exists()) { FileUtils.deleteDirectory(FILE_SOURCE_ROOT); } if (!FILES_DIRECTORY.mkdirs()) { throw new Exception("Could no create " + FILES_DIRECTORY.getAbsolutePath()); } if (!MAPPINGS_DIRECTORY.mkdirs()) { throw new Exception("Could no create " + MAPPINGS_DIRECTORY.getAbsolutePath()); } } catch (Exception e) { throw new RuntimeException(e); } }
From source file:de.unibi.cebitec.bibiserv.util.visualizer.AbstractTest.java
private static DataSource derbydb() throws Exception { EmbeddedDataSource ds = new EmbeddedDataSource(); String db = "test/testdb_" + System.currentTimeMillis(); // check if database exists File db_dir = new File(db); if (db_dir.exists()) { try {/*from ww w. jav a2 s . co m*/ FileUtils.deleteDirectory(db_dir); } catch (IOException e) { LOG.error(e); assertTrue(e.getMessage(), false); } } ds.setDatabaseName(db); ds.setCreateDatabase("create"); Connection con = ds.getConnection(); Statement stmt = con.createStatement(); // read SQL Statement from file BufferedReader r = new BufferedReader( new InputStreamReader(TestRAEDA.class.getResourceAsStream("/status.sql"))); String line; StringBuilder sql = new StringBuilder(); while ((line = r.readLine()) != null) { // skip commend lines if (!line.startsWith("--")) { sql.append(line); sql.append('\n'); } } r.close(); // execute sqlcmd's for (String sqlcmd : sql.toString().split(";")) { sqlcmd = sqlcmd.trim(); // ignore trailing/ending whitespaces sqlcmd = sqlcmd.replaceAll("\n\n", "\n"); // remove double newline if (sqlcmd.length() > 1) { // if string contains more than one char, execute sql cmd LOG.debug(sqlcmd + "\n"); stmt.execute(sqlcmd); } } // close stmt stmt.close(); return ds; }
From source file:com.amalto.core.storage.prepare.FullTextIndexCleaner.java
private static void doClean(Storage storage) { DataSource storageDataSource = storage.getDataSource(); if (!(storageDataSource instanceof RDBMSDataSource)) { throw new IllegalArgumentException("Storage to clean does not seem to be a RDBMS storage."); }// w w w.j av a 2s .co m RDBMSDataSource dataSource = (RDBMSDataSource) storageDataSource; if (dataSource.supportFullText()) { String dataSourceIndexDirectory = dataSource.getIndexDirectory(); File indexDirectory = new File(dataSourceIndexDirectory + '/' + storage.getName()); if (indexDirectory.exists()) { try { FileUtils.deleteDirectory(indexDirectory); } catch (IOException e) { throw new IllegalStateException( "Could not successfully delete '" + indexDirectory.getAbsolutePath() + "'", e); } } else { LOGGER.warn("Directory '" + dataSourceIndexDirectory + "' does not exist. No need to clean full text indexes."); } } }
From source file:io.github.bunnyblue.droidfix.classcomputer.proguard.DiffClassUtil.java
public static void copyDiffClasses(ArrayList<ClassObject> diffClasses, String rootPath) { File rootDir = new File(rootPath); try {/*from w w w . ja v a2 s . c om*/ FileUtils.deleteDirectory(rootDir); } catch (IOException e1) { e1.printStackTrace(); } rootDir.mkdirs(); for (ClassObject classObject : diffClasses) { classObject.getClassName().replaceAll(".", File.separator); String subPath = classObject.getClassName().replaceAll("\\.", File.separator); if (subPath.lastIndexOf(File.separator) != -1) { subPath = subPath.substring(0, subPath.lastIndexOf(File.separator)); subPath = rootPath + File.separator + subPath; File subDir = new File(subPath); subDir.mkdirs(); File localClass = new File(classObject.getLocalPath()); try { FileUtils.copyFileToDirectory(localClass, subDir); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } System.err.println("Copy diff class " + localClass.getAbsolutePath()); } else { File localClass = new File(classObject.getLocalPath()); try { FileUtils.copyFileToDirectory(localClass, rootDir); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } System.err.println("Copy diff class " + localClass.getAbsolutePath()); } } }