List of usage examples for org.apache.commons.io FileUtils forceDelete
public static void forceDelete(File file) throws IOException
From source file:com.redhat.victims.VictimsResultCache.java
/** * Delete the cache entry for a given key. * /*from ww w . ja va 2s . com*/ * @param key * @throws VictimsException */ public void delete(String key) throws VictimsException { key = hash(key); try { FileUtils.forceDelete(FileUtils.getFile(location, key)); } catch (IOException e) { throw new VictimsException(String.format("Could not delete the cached entry from disk: %s", key), e); } }
From source file:com.pinterest.terrapin.storage.HFileReaderTest.java
@AfterClass public static void tearDown() throws Exception { hfileReader.close();/*from w w w . j ava2 s .c o m*/ FileUtils.forceDelete(new File(hfilePath)); }
From source file:eu.openanalytics.rsb.message.MultiFilesJob.java
@Override protected void releaseResources() { try {/*www .ja va 2 s . c o m*/ FileUtils.forceDelete(temporaryDirectory); } catch (final IOException ioe) { throw new RuntimeException("Can't release resources of: " + this, ioe); } }
From source file:de.fabianonline.telegram_backup.ApiStorage.java
public void deleteDc() { if (this.do_save) { try {/*from w w w .ja v a 2s.c om*/ FileUtils.forceDelete(this.file_dc); } catch (IOException e) { e.printStackTrace(); } } }
From source file:com.github.brandtg.switchboard.LevelDbBasedLogIndex.java
@Override public void clear() throws IOException { synchronized (dbs) { for (Map.Entry<String, DB> entry : dbs.entrySet()) { File dbFile = new File(dbRoot, entry.getKey()); entry.getValue().close();// w w w. j a v a2s. co m FileUtils.forceDelete(dbFile); LOG.info("Deleted {}", dbFile); } dbs.clear(); } }
From source file:de.blizzy.documentr.repository.ProjectRepositoryManager.java
ILockedRepository createCentralRepository(boolean bare, User user) throws IOException, GitAPIException { if (centralRepoDir.isDirectory()) { throw new IllegalStateException("repository already exists: " + centralRepoDir.getAbsolutePath()); //$NON-NLS-1$ }//from w w w. j a v a 2s.co m ILock lock = lockManager.lockAll(); try { Repository repo = null; File gitDir = new File(centralRepoDir, ".git"); //$NON-NLS-1$ try { RepositoryBuilder builder = new RepositoryBuilder().setGitDir(gitDir); if (bare) { builder.setBare(); } repo = builder.build(); repo.create(); } finally { RepositoryUtil.closeQuietly(repo); } File tempGitDir = new File(new File(reposDir, CENTRAL_REPO_NAME + "_temp"), ".git"); //$NON-NLS-1$ //$NON-NLS-2$ Repository tempRepo = null; try { tempRepo = Git.cloneRepository().setURI(gitDir.toURI().toString()).setDirectory(tempGitDir).call() .getRepository(); Git git = Git.wrap(tempRepo); PersonIdent ident = new PersonIdent(user.getLoginName(), user.getEmail()); git.commit().setAuthor(ident).setCommitter(ident).setMessage("init").call(); //$NON-NLS-1$ git.push().call(); } finally { RepositoryUtil.closeQuietly(tempRepo); } FileUtils.forceDelete(tempGitDir.getParentFile()); } finally { lockManager.unlock(lock); } return getCentralRepository(bare); }
From source file:net.nicholaswilliams.java.teamcity.plugin.linux.TestAbstractLinuxPropertiesLocator.java
@Test public void testLocateProperties02() throws IOException { File pluginRoot = new File("."); File versionFile = new File(pluginRoot, "version.properties"); FileUtils.writeStringToFile(versionFile, ""); final Capture<Map<String, String>> capture = new Capture<Map<String, String>>(); this.locator.locateLinuxProperties(capture(capture)); expectLastCall().andAnswer(new IAnswer<Void>() { @Override// w ww .java 2 s .co m public Void answer() throws Throwable { assertTrue("The properties map should be empty.", capture.getValue().isEmpty()); capture.getValue().put("yourLinuxProperty02", "3.9.1"); return null; } }); replay(this.locator); try { Map<String, String> properties = this.locator.locateProperties(pluginRoot); assertNotNull("The properties should not be null.", properties); assertEquals("The linux property is not correct.", "3.9.1", properties.get("yourLinuxProperty02")); assertFalse("The version property should not be present.", properties.containsKey(LinuxPropertiesLocator.PLUGIN_VERSION_KEY)); } finally { FileUtils.forceDelete(versionFile); } }
From source file:com.uwsoft.editor.data.manager.SceneDataManager.java
private void deleteScene(String sceneName) { ArrayList<SceneVO> scenes = dataManager.currentProjectInfoVO.scenes; SceneVO sceneToDelete = null;/* w w w . j av a2s . c o m*/ for (SceneVO scene : scenes) { if (scene.sceneName.equals(sceneName)) { sceneToDelete = scene; break; } } if (sceneToDelete != null) { scenes.remove(sceneToDelete); } dataManager.currentProjectInfoVO.scenes = scenes; String projPath = dataManager.getCurrentWorkingPath() + "/" + dataManager.currentProjectVO.projectName; try { FileUtils.writeStringToFile(new File(projPath + "/project.dt"), dataManager.currentProjectInfoVO.constructJsonString(), "utf-8"); FileUtils.forceDelete(new File(projPath + "/scenes/" + sceneName + ".dt")); } catch (IOException e) { e.printStackTrace(); } }
From source file:com.sonarsource.lits.IssuesChecker.java
private static void forceDelete(File file) { if (file.exists()) { try {//w w w . j ava 2s. co m FileUtils.forceDelete(file); } catch (IOException e) { throw Throwables.propagate(e); } } }
From source file:com.meltmedia.cadmium.core.git.GitService.java
public static GitService cloneRepo(String uri, String dir) throws Exception { if (dir == null || !FileSystemManager.exists(dir)) { log.debug("Cloning \"" + uri + "\" to \"" + dir + "\""); CloneCommand clone = Git.cloneRepository(); clone.setCloneAllBranches(false); clone.setCloneSubmodules(false); if (dir != null) { clone.setDirectory(new File(dir)); }// www .j a v a2s . c o m clone.setURI(uri); try { return new GitService(clone.call()); } catch (Exception e) { if (new File(dir).exists()) { FileUtils.forceDelete(new File(dir)); } throw e; } } return null; }