List of usage examples for org.apache.commons.io FileUtils forceDelete
public static void forceDelete(File file) throws IOException
From source file:launcher.workflow.logs.UploadLogsWorkflow.java
public static void begin(final Settings launcherCfg, final String license) { WorkflowStep prepare = new WorkflowStep("Preparing to upload logs.", new WorkflowAction() { @Override//w ww . j a va2s .c o m public boolean act() { String licenseId = license; if (license.isEmpty()) { licenseId = "nolicense"; } LogsWorkflowData.LogID = launcherCfg.windowTitle.replaceAll(" ", "") + "--" + licenseId + "--" + UUID.randomUUID(); LogsWorkflowData.LogsArchive = new File(LogsWorkflowData.LogID + ".zip"); LogsWorkflowData.Logs = new File(launcherCfg.logsDirectory); if (!LogsWorkflowData.Logs.exists()) { LaunchLogger.error("No logs were found to upload."); return false; } return true; } }); WorkflowStep archive = new WorkflowStep("Archiving the logs directory", new WorkflowAction() { @Override public boolean act() { WorkflowWindowManager.setProgressVisible(true); Archive.zipDir(LogsWorkflowData.Logs, LogsWorkflowData.LogsArchive); WorkflowWindowManager.setProgressVisible(false); return true; } }); WorkflowStep upload = new WorkflowStep("Uploading logs archive.", new WorkflowAction() { @Override public boolean act() throws Exception { WorkflowWindowManager.setProgressVisible(true); REST.fileUpload(LogsWorkflowData.LogsArchive.getAbsoluteFile(), launcherCfg.logUploadApi); WorkflowWindowManager.setProgressVisible(false); LaunchLogger.info("Thank you for uploading your logs!"); LaunchLogger.info("Log ID: " + LogsWorkflowData.LogID); return true; } }); WorkflowStep cleanup = new WorkflowStep("Cleaning up temporary files.", new WorkflowAction() { @Override public boolean act() throws Exception { FileUtils.forceDelete(LogsWorkflowData.LogsArchive); return true; } }); prepare.setOnSuccess(archive); archive.setOnSuccess(upload); upload.setOnSuccess(cleanup); prepare.execute(); }
From source file:kaljurand_at_gmail_dot_com.diktofon.MyFileUtils.java
public static void deleteFile(File f) throws IOException { FileUtils.forceDelete(f); }
From source file:com.bbc.remarc.util.ResourceManager.java
public static boolean deleteResourceForId(String resourceDir, ResourceType resourceType, String id) { log.debug("deleting resources for id " + id); boolean success = true; File contentDir;// www. ja v a 2s . c o m //get folder by resourceType switch (resourceType) { case IMAGE: contentDir = new File(resourceDir + Configuration.IMAGE_DIR_NAME); break; case AUDIO: contentDir = new File(resourceDir + Configuration.AUDIO_DIR_NAME); break; case VIDEO: contentDir = new File(resourceDir + Configuration.VIDEO_DIR_NAME); break; default: throw new RuntimeException("ERROR! Trying to delete content for invalid type " + resourceType); } //get all files that match the id & delete FileFilter fileFilter = new WildcardFileFilter(id + ".*"); File[] files = contentDir.listFiles(fileFilter); for (File f : files) { try { FileUtils.forceDelete(f); log.debug("deleted file " + f.getPath()); } catch (IOException e) { log.error("ERROR! couldn't delete file " + f.getPath()); success = false; break; } } return success; }
From source file:edu.uci.ics.hyracks.control.common.deployment.DeploymentUtils.java
/** * undeploy an existing deployment//from ww w.ja v a2 s.com * * @param deploymentId * the deployment id * @param container * @param ctx * @throws HyracksException */ public static void undeploy(DeploymentId deploymentId, IJobSerializerDeserializerContainer container, ServerContext ctx) throws HyracksException { container.removeJobSerializerDeserializer(deploymentId); String rootDir = ctx.getBaseDir().toString(); String deploymentDir = rootDir.endsWith(File.separator) ? rootDir + DEPLOYMENT + File.separator + deploymentId : rootDir + File.separator + DEPLOYMENT + File.separator + deploymentId; try { File dFile = new File(deploymentDir); if (dFile.exists()) { FileUtils.forceDelete(dFile); } } catch (Exception e) { throw new HyracksException(e); } }
From source file:com.splunk.shuttl.archiver.bucketlock.SimpleFileLockTwoJVMsTest.java
private void deleteFileToLock() { try {/* w w w .j ava2 s .com*/ FileUtils.forceDelete(fileToLock); } catch (IOException e) { TUtilsTestNG.failForException("Tried force delete on" + " file, got IOException", e); } }
From source file:net.erdfelt.android.sdkfido.project.Dir.java
public void delete(String path) throws IOException { File file = getFile(path);// w ww. java2s .c o m if (!file.exists()) { return; // Nothing to delete. } FileUtils.forceDelete(file); }
From source file:com.alibaba.jstorm.utils.PathUtils.java
public static void rmr(String path) throws IOException { LOG.debug("Rmr path " + path); if (exists_file(path)) { FileUtils.forceDelete(new File(path)); }/*from w w w . j a v a2 s. c o m*/ }
From source file:de.flapdoodle.embedmongo.Files.java
public static boolean forceDelete(File fileOrDir) { boolean ret = false; try {//from w ww . j a v a 2 s . c o m if (fileOrDir != null) { FileUtils.forceDelete(fileOrDir); _logger.info("Could delete " + fileOrDir); ret = true; } } catch (IOException e) { _logger.warning("Could not delete " + fileOrDir + ". Will try to delete it again when program exits."); try { FileUtils.forceDeleteOnExit(fileOrDir); ret = true; } catch (IOException ioe) { _logger.severe("Could not delete " + fileOrDir); throw new IllegalStateException("Could not delete " + fileOrDir); } } return ret; }
From source file:io.druid.data.input.impl.PrefetchableTextFilesFirehoseFactoryTest.java
@BeforeClass public static void setup() throws IOException { testDir = File.createTempFile(PrefetchableTextFilesFirehoseFactoryTest.class.getSimpleName(), "testDir"); FileUtils.forceDelete(testDir); FileUtils.forceMkdir(testDir);//from w w w.ja va2s. c o m firehoseTempDir = File.createTempFile(PrefetchableTextFilesFirehoseFactoryTest.class.getSimpleName(), "baseDir"); FileUtils.forceDelete(firehoseTempDir); FileUtils.forceMkdir(firehoseTempDir); for (int i = 0; i < 10; i++) { // Each file is 1390 bytes try (final Writer writer = new BufferedWriter(new FileWriter(new File(testDir, "test_" + i)))) { for (int j = 0; j < 100; j++) { final String a = (20171220 + i) + "," + i + "," + j + "\n"; writer.write(a); } } } }
From source file:de.jcup.code2doc.generator.docbook.XMLSpecificationFileGenerator.java
@Override protected OutputFileSupport createOutputFileSupport() { return new OutputFileSupport() { @Override// w w w . j av a 2 s. c o m protected void handleExistingFile(File outputFile) throws IOException { FileUtils.forceDelete(outputFile); } @Override protected String getFileExtension() { return "xml"; } }; }