List of usage examples for org.apache.commons.io FileUtils cleanDirectory
public static void cleanDirectory(File directory) throws IOException
From source file:mesclasses.util.FileSaveUtil.java
public static void restoreArchive(File archiveFile) throws IOException { FileConfigurationManager conf = FileConfigurationManager.getInstance(); if (!ZipUtil.containsEntry(archiveFile, FileConfigurationManager.SAVE_FILE)) { AppLogger.notif("Archivage : ", "Le fichier " + archiveFile.getName() + " n'est pas une archive valide"); return;//from w ww .ja v a2s . c o m } FileUtils.cleanDirectory(new File(conf.getSaveDir())); ZipUtil.unpack(archiveFile, new File(conf.getSaveDir())); }
From source file:com.zotoh.maedr.test.flow.BaseJUT.java
@AfterClass public static void finz() { if (_p12File != null) _p12File.delete();/*from w ww . j a v a 2 s. co m*/ if (_appDir != null) try { FileUtils.cleanDirectory(_appDir); FileUtils.deleteQuietly(_appDir); } catch (Exception e) { } }
From source file:net.sourceforge.atunes.kernel.modules.lyrics.LyricsCache.java
/** * Clears the cache// w w w . j av a 2 s .c o m * * @return If an IOException occured during clearing */ public static synchronized boolean clearCache() { try { FileUtils.cleanDirectory(lyricsCacheDir); } catch (IOException e) { logger.info(LogCategories.FILE_DELETE, "Could not delete all files from lyricsr cache"); return true; } return false; }
From source file:com.meltmedia.cadmium.maven.ArtifactResolverTest.java
@Test public void testResolveArtifact() throws Exception { File localRepo = new File("./target/.m2"); if (localRepo.exists()) { FileUtils.cleanDirectory(localRepo); }/*w ww .ja va 2s.c om*/ FileUtils.forceMkdir(localRepo); ArtifactResolver resolver = new ArtifactResolver(null, localRepo.getAbsolutePath()); File artifact = resolver.resolveMavenArtifact("org.apache.maven:maven-artifact:3.0.4"); System.err.println("Artifact is downloaded to: " + artifact.getAbsolutePath()); assertTrue("Artifact not downloaded.", artifact.exists()); assertTrue("Artifact cannot be read.", artifact.canRead()); assertTrue("Artifact points to empty file.", artifact.lastModified() > 0l); }
From source file:at.ac.tuwien.dsg.cloudlyra.utils.IOUtils.java
public static void cleanTempData() { String tomcatTempFolder = System.getProperty("java.io.tmpdir"); File dir = new File(tomcatTempFolder); try {//from w w w.j a va 2 s. c o m FileUtils.cleanDirectory(dir); } catch (IOException ex) { Logger.getLogger(IOUtils.class.getName()).log(Level.SEVERE, null, ex); } }
From source file:iit.cs570.assign1.web.bean.IndexerBean.java
public String index() { IndexerIntf indexer;/*from w ww . ja va 2s .c o m*/ try { if (similarity.equalsIgnoreCase("TFIDF")) { FileUtils.cleanDirectory(new File(TheCrawlersConstants.INDEX_DIR_TFIDF)); indexer = new TFIDFIndexer(TheCrawlersConstants.INDEX_DIR_TFIDF); } else if (similarity.equalsIgnoreCase("BM25")) { FileUtils.cleanDirectory(new File(TheCrawlersConstants.INDEX_DIR_BM25)); indexer = new BM25Indexer(TheCrawlersConstants.INDEX_DIR_BM25); } else { FileUtils.cleanDirectory(new File(TheCrawlersConstants.INDEX_DIR_TFIDF)); indexer = new TFIDFIndexer(TheCrawlersConstants.INDEX_DIR_TFIDF); } int numIndexed; long startTime = System.currentTimeMillis(); numIndexed = indexer.createIndex(TheCrawlersConstants.DATA_DIR, new HTMLFileFilter()); long endTime = System.currentTimeMillis(); indexer.close(); System.out.println(numIndexed + " File indexed, time taken: " + (endTime - startTime) + " ms"); return TheCrawlersConstants.SUCCESS; } catch (Exception e) { System.out.println("Exception occured in Indexing module--> " + e.getMessage()); return TheCrawlersConstants.FAILURE; } }
From source file:com.github.jjYBdx4IL.utils.SimpleAppConfigTest.java
@Before public void before() throws IOException { FileUtils.cleanDirectory(TEMP_DIR); SimpleAppConfig.setForceDir(TEMP_DIR); }
From source file:com.doplgangr.secrecy.FileSystem.storage.java
public static void DeleteRecursive(java.io.File directory) { try {/* w ww .ja v a 2 s . c o m*/ Collection files = FileUtils.listFiles(directory, null, true); for (Object file : files) purgeFile((File) file); } catch (Exception e) { Util.log(e); } finally { try { FileUtils.cleanDirectory(directory); } catch (Exception ignored) { } } }
From source file:ezbake.groups.cli.commands.CommandTestBase.java
@After public void cleanFileSystem() throws IOException { FileUtils.cleanDirectory(folder.getRoot()); }
From source file:com.yahoo.maven.visitor.VisitorTest.java
@Before public void setUp() throws Exception { injector = Guice.createInjector(Modules.override(Modules.combine(new TestModule(), new AbstractModule() { @Override/* ww w . j ava2 s .c o m*/ protected void configure() { bind(Path.class).annotatedWith(ScratchSpace.class) .toInstance(Paths.get("target", "visitor", name.getMethodName())); } })).with(getOverrides())); injector.injectMembers(this); Files.createDirectories(scratchSpace); FileUtils.cleanDirectory(scratchSpace.toFile()); }