List of usage examples for org.apache.commons.io FileUtils cleanDirectory
public static void cleanDirectory(File directory) throws IOException
From source file:eu.planets_project.services.utils.ZipUtilsTest.java
/** * Test method for {@link eu.planets_project.services.utils.ZipUtils#insertFileInto(java.io.File, java.io.File, java.lang.String)}. * @throws IOException /*from w ww . j av a2 s . c o m*/ */ @Test public void testGetFileFrom() throws IOException { FileUtils.cleanDirectory(outputFolder); File zip = ZipUtils.createZip(TEST_FILE_FOLDER, outputFolder, "zipUtilsTestGetFile.zip", true); System.out.println("Zip created. Please find it here: " + zip.getAbsolutePath()); File fromZip = ZipUtils.getFileFrom(zip, "docs", outputFolder); System.out.println("File extracted. Please find it here: " + fromZip.getAbsolutePath()); }
From source file:com.alibaba.jstorm.cache.rocksdb.RocksDbFactory.java
public static void cleanRocksDbLocalDir(String rocksDbDir) throws IOException { File file = new File(rocksDbDir); if (file.exists()) { FileUtils.cleanDirectory(file); } else {/*from ww w . j av a2 s.co m*/ FileUtils.forceMkdir(file); } }
From source file:me.xingrz.finder.ZipFinderActivity.java
private void deleteTempFile() { if (getExternalCacheDir() == null) { Log.d(TAG, "nothing to clean"); }/*from w ww .j a va 2s . c o m*/ try { // FIXME: sub dir in the future FileUtils.cleanDirectory(getExternalCacheDir()); Log.d(TAG, "cleaned cache dir"); } catch (IOException e) { Log.e(TAG, "failed to clean cache dir", e); } }
From source file:es.uvigo.ei.sing.adops.datatypes.SingleExperiment.java
@Override public void clear() { final FileFilter filter = new FileFilter() { @Override/* w ww . ja va 2 s . c om*/ public boolean accept(File pathname) { return !(pathname.equals(SingleExperiment.this.getNotesFile()) || pathname.equals(SingleExperiment.this.getPropertiesFile()) || pathname.equals(SingleExperiment.this.getFastaFile()) || pathname.equals(SingleExperiment.this.getNamesFile()) || pathname.equals(SingleExperiment.this.getFilesFolder())); } }; for (File file : this.getFolder().listFiles(filter)) { if (file.isFile()) file.delete(); else if (file.isDirectory()) try { FileUtils.deleteDirectory(file); } catch (IOException e) { } } try { FileUtils.cleanDirectory(this.getFilesFolder()); } catch (IOException e) { e.printStackTrace(); } this.result = null; }
From source file:architecture.ee.web.community.profile.DefaultProfileManager.java
protected synchronized File getImageDir() { if (imageDir == null) { imageDir = ApplicationHelper.getRepository().getFile("images"); if (!imageDir.exists()) { boolean result = imageDir.mkdir(); if (!result) log.error((new StringBuilder()).append("Unable to create image directory: '").append(imageDir) .append("'").toString()); getImageCacheDir(); // new File(imageDir, "cache"); getImageTempDir();//from w ww.j av a 2s .c o m } else { File dir = getImageTempDir(); try { FileUtils.cleanDirectory(dir); } catch (IOException e) { e.printStackTrace(); } } } return imageDir; }
From source file:com.legstar.coxb.gen.CoxbBindingGenerator.java
/** * Create the folder which will receive the generated classes. * <p/>// www .j a v a 2s. co m * Folder includes the COXB package path if any. When the COXB package path * is provided, the output is cleaned from any previous generation * artifacts. * * @param coxbGenModel the generation model * * @return the generation folder * @throws CoxbGenException if generation folder cannot be determined */ public static File createOutputFolder(final CoxbGenModel coxbGenModel) throws CoxbGenException { try { File outputFolder = coxbGenModel.getCoxbSrcDir(); if (coxbGenModel.getCoxbPackageName() != null) { outputFolder = new File(coxbGenModel.getCoxbSrcDir(), CodeGenUtil.relativeLocation(coxbGenModel.getCoxbPackageName())); } CodeGenUtil.checkDirectory(outputFolder, true); if (coxbGenModel.getCoxbPackageName() != null) { FileUtils.cleanDirectory(outputFolder); } return outputFolder; } catch (IOException e) { throw new CoxbGenException(e); } }
From source file:com.atlassian.jira.plugin.PluginFactoryAndLoaderRegistrar.java
public PluginLoader getBundledPluginsLoader(List<PluginFactory> pluginFactories) { final String bundledPluginOverride = jiraSystemProperties.getProperty("jira.dev.bundledplugins.url"); final String bundledPluginUrlString; if (bundledPluginOverride != null) { bundledPluginUrlString = bundledPluginOverride; log.warn("Bundled plugins being loaded from override " + bundledPluginUrlString); } else {/*from w ww. jav a2s . c o m*/ String bundledPluginPath = servletContextFactory.getServletContext() .getRealPath(BUNDLED_PLUGIN_LOCATION); if (bundledPluginPath == null) { throw new IllegalStateException("Running JIRA from a packed WAR is not supported." + " Configure your Servlet container to unpack the WAR before running it." + " (Cannot resolve real path for '" + BUNDLED_PLUGIN_LOCATION + "')"); } else { bundledPluginUrlString = new File(bundledPluginPath).toURI().toString(); } } // Directory prior version exploded atlassian-bundled-plugins.zip into. We continue to use // this as the directory required by the current BundledPluginLoader constructor. final File legacyBundledPluginsDirectory = pathFactory.getBundledPluginsDirectory(); try { // Clean out old copies of plugins from prior explosions FileUtils.cleanDirectory(legacyBundledPluginsDirectory); } catch (IOException eio) { // We don't use the directory any more, and there's not much we can do if we can't clean it, // so see if we can get a admin's attention. log.warn("Cannot clean '" + legacyBundledPluginsDirectory + "': " + eio.getMessage()); } try { final URL bundledPluginUrl = new URL(bundledPluginUrlString); // Note legacyBundlePluginsDirectory is unused since bundledPluginUrl is never a .zip // anymore. Once we have a more appropriate constructor (PLUGDEV-43) we should use that // and remove usage of legacyBundledPluginsDirectory, moving the cleanup code to an // upgrade task. // TODO: https://jdog.jira-dev.com/browse/JDEV-27508 return new BundledPluginLoader(bundledPluginUrl, legacyBundledPluginsDirectory, pluginFactories, pluginEventManager); } catch (MalformedURLException e) { throw new IllegalStateException( "Can't form url to bundled plugins directory at: " + BUNDLED_PLUGIN_LOCATION, e); } }
From source file:com.github.ipaas.ideploy.agent.util.SVNUtil.java
/** * svn??//from ww w.j av a2 s. co m * @param path svn * @param datumRevision * @param expectRevision * @param localPath ? * @throws Exception */ public static void getDelta(String path, long datumRevision, long expectRevision, String localPath) throws Exception { DefaultSVNOptions options = SVNWCUtil.createDefaultOptions(true); ISVNAuthenticationManager authManager = SVNWCUtil .createDefaultAuthenticationManager(Constants.CRS_REPOS_USER, Constants.CRS_REPOS_PWD); SVNClientManager svnClientManager = null; try { svnClientManager = SVNClientManager.newInstance(options, authManager); SVNRepository repository = svnClientManager .createRepository(SVNURL.parseURIEncoded(Constants.CRS_REPOS), true); Collection<SVNLog> logs = getLog(repository, path, datumRevision, expectRevision); // File localDict = new File(localPath); if (!localDict.exists()) { localDict.mkdirs(); } else { FileUtils.cleanDirectory(localDict); } // ??? getDelta4Add(repository, path, logs, localPath + Constants.UPDPKG_CODEDIR); // writeLogToFile(logs, new File(localPath + Constants.UPDPKG_UPDTXT)); } finally { if (svnClientManager != null) { svnClientManager.dispose(); } } }
From source file:ch.ivyteam.ivy.maven.InstallEngineMojo.java
private void removeOldEngineContent() throws MojoExecutionException { try {//from www .j a v a 2 s . c om FileUtils.cleanDirectory(getRawEngineDirectory()); } catch (IOException ex) { throw new MojoExecutionException( "Failed to clean outdated ivy Engine directory '" + getRawEngineDirectory() + "'.", ex); } }
From source file:com.surevine.gateway.scm.model.LocalRepoBean.java
public void emptyRepoDirectory() { final Path localDirectory = getRepoDirectory(); try {//ww w .j ava2 s .c o m FileUtils.cleanDirectory(localDirectory.toFile()); } catch (final IOException e) { // drop the exception } }