List of usage examples for org.apache.commons.io FileUtils forceDelete
public static void forceDelete(File file) throws IOException
From source file:com.asakusafw.testdriver.FlowPartTestDriver.java
/** * ????????/* w w w . ja va 2s . co m*/ * * @param flowDescription ?? */ public void runTest(FlowDescription flowDescription) { try { // ? String batchId = "flow"; String flowId = "part"; File compileWorkDir = driverContext.getCompilerWorkingDirectory(); if (compileWorkDir.exists()) { FileUtils.forceDelete(compileWorkDir); } FlowGraph flowGraph = flowDescriptionDriver.createFlowGraph(flowDescription); JobflowInfo jobflowInfo = DirectFlowCompiler.compile(flowGraph, batchId, flowId, "test.flowpart", FlowPartDriverUtils.createWorkingLocation(driverContext), compileWorkDir, Arrays.asList(new File[] { DirectFlowCompiler.toLibraryPath(flowDescription.getClass()) }), flowDescription.getClass().getClassLoader(), driverContext.getOptions()); JobflowExecutor executor = new JobflowExecutor(driverContext); driverContext.prepareCurrentJobflow(jobflowInfo); // ? executor.cleanWorkingDirectory(); // ???Excel?????HDFS??? if (createIndividually) { prepareIndividually(); } else { createAllInput(); } executor.runJobflow(jobflowInfo); // ???Excel???? if (loadIndividually) { loadAndInspectResultsIndividually(); } else { loadAndInspectResults(); } } catch (Exception e) { throw new RuntimeException(e); } finally { driverContext.cleanUpTemporaryResources(); } }
From source file:algorithm.F5Steganography.java
@Override public File encapsulate(File carrierFile, List<File> payloadList) throws IOException { String carrier = getCarrier(carrierFile); String payload = getPayloadPathString(carrierFile, payloadList.get(0)); String output = getOutputString(carrierFile); encapsulate(carrier, payload, output); FileUtils.forceDelete(new File(payload)); // tmp File outputFile = new File(output); if (outputFile.isFile()) { return outputFile; }//w ww. j a va 2 s . c o m return null; }
From source file:edu.isi.misd.scanner.network.worker.webapp.ResultsReleaseDelegate.java
@Override public void execute(DelegateExecution execution) throws Exception { if (!execution.hasVariable(BaseConstants.ID)) { throw new Exception("Variable not present: " + BaseConstants.ID); }/*ww w .jav a2 s .com*/ if (!execution.hasVariable(BaseConstants.REQUEST_URL)) { throw new Exception("Variable not present: " + BaseConstants.REQUEST_URL); } if (!execution.hasVariable(SITE_NAME)) { throw new Exception("Variable not present: " + SITE_NAME); } if (!execution.hasVariable(NODE_NAME)) { throw new Exception("Variable not present: " + NODE_NAME); } if (!execution.hasVariable(COMMENTS)) { throw new Exception("Variable not present: " + COMMENTS); } if (!execution.hasVariable(APPROVED)) { throw new Exception("Variable not present: " + APPROVED); } if (!execution.hasVariable(FILE_PATH)) { throw new Exception("Variable not present: " + FILE_PATH); } if (!execution.hasVariable(HOLDING_PATH)) { throw new Exception("Variable not present: " + HOLDING_PATH); } File outputFile = new File((String) execution.getVariable(FILE_PATH)); File holdingFile = new File((String) execution.getVariable(HOLDING_PATH)); String id = (String) execution.getVariable(BaseConstants.ID); String url = (String) execution.getVariable(BaseConstants.REQUEST_URL); String siteName = (String) execution.getVariable(SITE_NAME); String nodeName = (String) execution.getVariable(NODE_NAME); String approved = (String) execution.getVariable(APPROVED); String comments = (String) execution.getVariable(COMMENTS); if (!Boolean.parseBoolean(approved)) { log.info("Release approval rejected for request [" + id + "]." + " The following file will be deleted: " + holdingFile.getCanonicalPath()); try { writeRejectedServiceResponse(id, url, siteName, nodeName, comments, outputFile); } catch (Exception e) { log.warn("Could write service response output file " + outputFile.getCanonicalPath() + " : Exception: " + e); throw e; } try { FileUtils.forceDelete(holdingFile); } catch (Exception e) { log.warn("Could not delete output file from holding directory: " + holdingFile.getCanonicalPath()); throw e; } return; } if (outputFile.exists()) { try { FileUtils.forceDelete(outputFile); } catch (Exception e) { log.warn("Could not delete output file: " + outputFile.getCanonicalPath()); throw e; } } try { FileUtils.moveFile(holdingFile, outputFile); log.info("Release approval accepted for request [" + id + "]." + " The results file was moved from " + holdingFile.getCanonicalPath() + " to " + outputFile.getCanonicalPath()); } catch (Exception e) { log.warn("Unable to move file " + holdingFile.getCanonicalPath() + " to " + outputFile.getCanonicalPath()); throw e; } }
From source file:com.keybox.manage.util.SSHUtil.java
/** * delete SSH keys/*from www . j av a 2 s . co m*/ */ public static void deleteGenSSHKeys() { deletePvtGenSSHKey(); //delete public key try { File file = new File(PUB_KEY); FileUtils.forceDelete(file); } catch (Exception ex) { } }
From source file:com.wavemaker.tools.project.upgrade.swamis.WebServiceUpgrade.java
private void upgradeWebServices(WebServiceToolsManager wstm, UpgradeInfo upgradeInfo) throws IOException, JAXBException, WSDLException, NoSuchMethodException, ParserConfigurationException, SAXException, TransformerException { for (String serviceId : this.dsm.getServiceIds()) { Service service = this.dsm.getService(serviceId); if (service != null && WebServiceType.TYPE_NAME.equals(service.getType())) { if (serviceId.equals(FeedServiceDefinition.FEED_SERVICE_NAME)) { this.dsm.deleteService(FeedServiceDefinition.FEED_SERVICE_NAME); wstm.registerFeedService(); } else { File wsdlFile = wstm.getWSDLFile(serviceId); if (wsdlFile != null) { java.io.File tempDir = java.io.File.createTempFile("wmkrmsd", null); try { java.io.File tempWsdlFile = new java.io.File(tempDir, "temp.wsdl"); FileCopyUtils.copy(wsdlFile.getContent().asBytes(), tempWsdlFile); this.dsm.deleteService(serviceId); wstm.importWSDL(tempWsdlFile.getCanonicalPath(), null, true, null, null, null); } finally { try { FileUtils.forceDelete(tempDir); } catch (IOException e) { e.printStackTrace(); }// w ww .ja va 2 s.com } } } upgradeInfo.addVerbose("Upgraded " + serviceId); } } }
From source file:com.cognitivabrasil.repositorio.data.entities.Files.java
public void deleteFile() throws IOException { FileUtils.forceDelete(new java.io.File(getLocation())); }
From source file:com.netsteadfast.greenstep.util.JReportUtils.java
public static void deploy() throws ServiceException, Exception { logger.info("begin deploy..."); List<TbSysJreport> reports = sysJreportService.findListByParams(null); String reportDeployDirName = Constants.getDeployJasperReportDir() + "/"; File reportDeployDir = new File(reportDeployDirName); try {/* w w w . ja v a2s . c o m*/ if (reportDeployDir.exists()) { logger.warn("delete " + reportDeployDirName); FileUtils.forceDelete(reportDeployDir); } logger.warn("mkdir " + reportDeployDirName); FileUtils.forceMkdir(reportDeployDir); for (TbSysJreport report : reports) { deployReport(report); } } catch (IOException e) { e.printStackTrace(); logger.error(e.getMessage().toString()); } reportDeployDir = null; logger.info("end deploy..."); }
From source file:com.asakusafw.testdriver.JobFlowTestDriver.java
/** * ???????// w ww.j a v a 2 s. co m * @param jobFlowDescriptionClass ? * @throws RuntimeException ????? */ public void runTest(Class<? extends FlowDescription> jobFlowDescriptionClass) { try { JobflowExecutor executor = new JobflowExecutor(driverContext); // ? executor.cleanWorkingDirectory(); // ???Excel??? storeDatabase(); setLastModifiedTimestamp(new Timestamp(0L)); // ? JobFlowDriver jobFlowDriver = JobFlowDriver.analyze(jobFlowDescriptionClass); assertFalse(jobFlowDriver.getDiagnostics().toString(), jobFlowDriver.hasError()); JobFlowClass jobFlowClass = jobFlowDriver.getJobFlowClass(); String flowId = jobFlowClass.getConfig().name(); File compileWorkDir = driverContext.getCompilerWorkingDirectory(); if (compileWorkDir.exists()) { FileUtils.forceDelete(compileWorkDir); } FlowGraph flowGraph = jobFlowClass.getGraph(); JobflowInfo jobflowInfo = DirectFlowCompiler.compile(flowGraph, batchId, flowId, "test.jobflow", Location.fromPath(driverContext.getClusterWorkDir(), '/'), compileWorkDir, Arrays.asList(new File[] { DirectFlowCompiler.toLibraryPath(jobFlowDescriptionClass) }), jobFlowDescriptionClass.getClassLoader(), driverContext.getOptions()); driverContext.prepareCurrentJobflow(jobflowInfo); executor.runJobflow(jobflowInfo); // ???Excel??DB?? loadDatabase(); if (!testUtils.inspect()) { Assert.fail(testUtils.getCauseMessage()); } } catch (IOException e) { throw new RuntimeException(e); } finally { driverContext.cleanUpTemporaryResources(); } }
From source file:com.linkedin.pinot.query.aggregation.StarTreeQueriesTest.java
@BeforeClass public void beforeClass() throws Exception { testName = StarTreeQueriesTest.class.getSimpleName(); indexDir = new File(System.getProperty("java.io.tmpdir"), testName); if (indexDir.exists()) { FileUtils.forceDelete(indexDir); }/*from w w w . j ava 2 s. co m*/ System.out.println(indexDir); avroFile = new File(System.getProperty("java.io.tmpdir"), testName + ".avro"); if (avroFile.exists()) { FileUtils.forceDelete(avroFile); } avroFile.deleteOnExit(); createSampleAvroData(avroFile, numRecords, numTimeBuckets); final SegmentGeneratorConfig config = SegmentTestUtils.getSegmentGenSpecWithSchemAndProjectedColumns( avroFile, indexDir, "daysSinceEpoch", TimeUnit.DAYS, "testTable"); config.setSegmentNamePostfix("1"); config.setTimeColumnName("daysSinceEpoch"); // Set the star tree index config StarTreeIndexSpec starTreeIndexSpec = new StarTreeIndexSpec(); starTreeIndexSpec.setSplitExcludes(Arrays.asList("daysSinceEpoch")); starTreeIndexSpec.setMaxLeafRecords(4); config.getSchema().setStarTreeIndexSpec(starTreeIndexSpec); final SegmentIndexCreationDriver driver = SegmentCreationDriverFactory.get(null); driver.init(config); driver.build(); File segmentFile = new File(indexDir, driver.getSegmentName()); indexSegment = ColumnarSegmentLoader.load(segmentFile, ReadMode.heap); }
From source file:jmassivesort.algs.chunks.OneOffChunkReader_LF_ASCII_Test.java
private void checkMergedChunks(int fromChunksNum, int toChunksNum, File src, String outFileName) throws IOException { for (int i = fromChunksNum; i <= toChunksNum; i++) { File out = createTmpFile(src.getParent(), outFileName + "_" + i); try (BufferedOutputStream outWr = new BufferedOutputStream(new FileOutputStream(out))) { readChunksWriteToOutput(i, src, outWr); outWr.close();/*w w w .j a va 2 s. c o m*/ assertEquals("failed on numChunks=" + i, FileUtils.checksumCRC32(src), FileUtils.checksumCRC32(out)); FileUtils.forceDelete(out); } } }