List of usage examples for org.apache.commons.io FileUtils copyFile
public static void copyFile(File srcFile, File destFile) throws IOException
From source file:ch.unibas.fittingwizard.mocks.MockMultipoleGaussScript.java
@Override public MultipoleGaussOutput execute(MultipoleGaussInput input) { File specificMoleculeDir = new File(moleculesDir, input.getMoleculeName()); File logOutfile = new File(specificMoleculeDir, input.getMoleculeName() + logExtension); File punOutfile = new File(specificMoleculeDir, input.getMoleculeName() + punExtension); File cubeOutfile = new File(specificMoleculeDir, input.getMoleculeName() + cubeExtension); File vdwOutfile = new File(specificMoleculeDir, input.getMoleculeName() + vdwExtension); File precomputedDataDir = new File(moleculeTestdataDir, input.getMoleculeName()); for (String fileExtension : filesToCopy) { File precomputedFile = new File(precomputedDataDir, input.getMoleculeName() + fileExtension); try {//from www .jav a2 s .c o m FileUtils.copyFile(precomputedFile, new File(specificMoleculeDir, input.getMoleculeName() + fileExtension)); } catch (IOException e) { logger.error(e.getStackTrace()); throw new RuntimeException("Could not copy precomputed file " + precomputedFile); } } MultipoleGaussOutput output = new MultipoleGaussOutput(true, logOutfile, punOutfile, cubeOutfile, vdwOutfile); return output; }
From source file:de.rub.syssec.saaf.analysis.steps.hash.SSDeep.java
/** * Generate hashes for all smali files.//from ww w.j a va 2 s . c o m */ @Override public void generateHash(ApplicationInterface apk, boolean includeFilesFromAdPackages) throws IOException { File tmpDir = new File(apk.getApplicationDirectory() + File.separator + TMP); for (ClassInterface f : apk.getAllSmaliClasss(includeFilesFromAdPackages)) { // write smali file File target = new File( tmpDir.getAbsolutePath() + File.separator + f.getFullClassName(false) + ".smali"); FileUtils.copyFile(f.getFile(), target); f.setSsdeepHash(calculateFuzzyHash(target)); target.delete(); /* * generate ssdeep for methods, this is not used, because usually methods are too short to give reliable ssdeep results * for(MethodInterface m: f.getMethods()){ //take the name of the class and append the methodname+ parameters File methodTarget= new File (target.getAbsolutePath().substring(0, target.getAbsolutePath().length()-6)); methodTarget = new File(methodTarget.getAbsolutePath()+"_"+m.getName()+"__"+m.getParameterString()+".smali"); //write the method data to a file makeFileforMethod(m, methodTarget); m.setHash(calcHash(methodTarget)); // System.out.println(m.getName()+" "+m.getParameterString()+" "+m.getHash()); } */ } try { FileUtils.deleteDirectory(tmpDir); } catch (IOException e) { LOGGER.error("Could not delete directory. e=" + e.getMessage()); } }
From source file:de.langmi.spring.batch.examples.complex.file.renamefile.partition.RenameFileListener.java
@Override public ExitStatus afterStep(StepExecution stepExecution) { // get business key String businessKey = (String) stepExecution.getExecutionContext() .get(BatchConstants.CONTEXT_NAME_BUSINESS_KEY); try {// w ww . j ava 2 s. c om String path = this.outputFileResource.getFile().getParent(); String newFilePathAndName = path + File.separator + businessKey + ".txt"; FileUtils.copyFile(outputFileResource.getFile(), new File(newFilePathAndName)); LOG.info("copied:" + this.outputFileResource.getFile().getPath() + " to:" + newFilePathAndName); // deletion here is not good, the itemstream will be closed after // this afterStep method is called // so get it deleted on jvm exit this.outputFileResource.getFile().deleteOnExit(); LOG.info("deleteOnExit for:" + this.outputFileResource.getFile().getPath()); } catch (Exception ex) { return new ExitStatus(ExitStatus.FAILED.getExitCode(), ex.getMessage()); } return stepExecution.getExitStatus(); }
From source file:Cursling.deleteNotification.java
public String _doDelete(String notification_name) { isdeleted = false;/*from w w w . j a va 2 s . c om*/ try { File inFile = new File(input_notification_file_del); if (!inFile.isFile()) { logger.info("Failed to Delete. Data file not found."); return ("failed"); } storeUpdate = new File(input_notification_file_del); File tempFile = new File(inFile.getAbsolutePath() + ".tmp"); BufferedReader br = new BufferedReader(new FileReader(input_notification_file_del)); PrintWriter pw = new PrintWriter(new FileWriter(tempFile)); String line = null; while ((line = br.readLine()) != null) { if (!line.equalsIgnoreCase("")) { if (line.startsWith(notification_name + "=") || line.startsWith(notification_name + " =")) { isdeleted = true; pw.flush(); } else { pw.println(line); pw.flush(); } } else { //do nothing } } pw.close(); br.close(); //Rename the new file to the filename the original file had. if (tempFile.canRead()) { Long before = storeUpdate.lastModified(); FileUtils.copyFile(tempFile, storeUpdate); Long after = storeUpdate.lastModified(); if (before.equals(after)) { logger.info("failed to delete Notification Group " + notification_name); return ("failed"); } else if (isdeleted == true) { logger.info("Notification Group " + notification_name + " Deleted."); obj_convert._doConvert(); return ("deleted"); } else { logger.info("Failed to delete Notification Group " + notification_name + " . Notification Group not found."); return ("not_found"); } } else { logger.info("failed to delete Notification Group " + notification_name); return ("failed"); } } catch (FileNotFoundException ex) { logger.info("failed to delete Notification Group " + notification_name); logger.error("Error : " + ex); return ("failed"); } catch (IOException ex) { logger.info("failed to delete Notification Group " + notification_name); logger.error("Error : " + ex); return ("failed"); } }
From source file:com.arksoft.epamms.EpammsTest.java
/** * Called at the beginning of the test to reset the DB. *//*from www. jav a2 s . com*/ @BeforeClass public static void resetDB() throws IOException { System.out.println("CWD = " + System.getProperty("user.dir")); // Copy the "base" sqlite file to a test one so we can commit changes // as part of the tests. File srcFile = new File("./src/test/resources/testdata/ePamms/sqlite/base.db"); File destFile = new File("./src/test/resources/testdata/ePamms/sqlite/test.db"); FileUtils.copyFile(srcFile, destFile); }
From source file:com.action.FileuploadAction.java
public String jqXmlupload() { String realPath = ReadProperties.getProperties("path"); System.out.println(realPath); try {/*from w w w . j a v a 2s . c om*/ System.out.println("==============" + filenameFileName.substring(filenameFileName.indexOf('.') + 1)); if ("xml".equals(filenameFileName.substring(filenameFileName.indexOf('.') + 1))) { if (filename != null) { File savaFile = new File(new File(realPath), filenameFileName); if (!savaFile.getParentFile().exists()) { savaFile.getParentFile().mkdirs(); } FileUtils.copyFile(filename, savaFile); ActionContext.getContext().put("message", "?????"); } File file = new File(realPath + filenameFileName); //xml?? Dom4jJQXML djqxml = new Dom4jJQXML(); djqxml.XMLDom4j(file); return SUCCESS; } else { ActionContext.getContext().put("message", "???xml??"); return ERROR; } } catch (Exception e) { ActionContext.getContext().put("message", "?" + e); return ERROR; } }
From source file:com.cognifide.qa.bb.logging.entries.ScreenshotEntry.java
/** * Constructs ScreenshotEntry. Creates a screenshot file. * * @param webDriver Constructor will use this WebDriver instance to create the screenshot * @param fileCreator report file creator * @param message screenshot entry message * @throws IOException Thrown when it's not possible to create the screenshot file. *//*from www.j ava2 s .co m*/ public ScreenshotEntry(WebDriver webDriver, ReportFileCreator fileCreator, String message) throws IOException { super(); this.screenshotFile = fileCreator.getReportFile("png"); this.message = message; final File scrFile = ((TakesScreenshot) webDriver).getScreenshotAs(OutputType.FILE); FileUtils.copyFile(scrFile, screenshotFile); }
From source file:hu.bme.mit.sette.tools.spf.SpfGenerator.java
@Override protected void afterWriteRunnerProject(EclipseProject eclipseProject) throws IOException, SetteException { createGeneratedFiles();/*from w w w . j a v a 2 s . co m*/ File buildXml = new File(getRunnerProjectSettings().getBaseDirectory(), "build.xml"); FileUtils.copyFile(getTool().getDefaultBuildXml(), buildXml); }
From source file:cat.calidos.morfeu.webapp.DocumentSaveUITest.java
@After public void teardown() throws Exception { if (backupFile.exists()) { // System.err.println("\t"+backupFile+" ->"+contentFile); FileUtils.copyFile(backupFile, contentFile); }// www.ja va 2s . c o m }
From source file:hu.bme.mit.trainbenchmark.generator.rdf.RdfSerializer.java
@Override public void initModel() throws IOException { // source file final String modelFlavor = gc.getModelFlavor(); final String extension = gc.getExtension(); final String postfix = modelFlavor + "." + extension; final String srcFilePath = gc.getConfigBase().getWorkspaceDir() + RDF_METAMODEL_DIR + "railway" + postfix; final File srcFile = new File(srcFilePath); // destination file final String destFilePath = gc.getConfigBase().getModelPathWithoutExtension() + postfix; final File destFile = new File(destFilePath); // this overwrites the destination file if it exists FileUtils.copyFile(srcFile, destFile); file = new BufferedWriter(new FileWriter(destFile, true)); }