List of usage examples for org.apache.commons.io FileUtils copyFile
public static void copyFile(File srcFile, File destFile) throws IOException
From source file:io.selendroid.builder.SelendroidServerBuilderTest.java
@Test public void testShouldBeAbleToResignAnSignedApp() throws Exception { SelendroidServerBuilder builder = getDefaultBuilder(); File androidApp = File.createTempFile("testapp", ".apk"); FileUtils.copyFile(new File(APK_FILE), androidApp); AndroidApp app = builder.resignApp(androidApp); Assert.assertEquals("resigned-" + androidApp.getName(), new File(app.getAbsolutePath()).getName()); // Verify that apk is signed CommandLine cmd = new CommandLine(AndroidSdk.aapt()); cmd.addArgument("list", false); cmd.addArgument(app.getAbsolutePath(), false); String output = ShellCommand.exec(cmd); assertResultDoesNotContainFile(output, "META-INF/CERT.RSA"); assertResultDoesNotContainFile(output, "META-INF/CERT.SF"); assertResultDoesContainFile(output, "META-INF/ANDROIDD.SF"); assertResultDoesContainFile(output, "META-INF/ANDROIDD.RSA"); assertResultDoesContainFile(output, "AndroidManifest.xml"); }
From source file:com.action.FileuploadAction.java
public String iufoXmlupload() { String realPath = ReadProperties.getProperties("path"); System.out.println(realPath); try {//from ww w . ja v a2 s .c o m 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?? Dom4jIUFOXML djqxml = new Dom4jIUFOXML(); 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:edu.isistan.carcha.lsa.LSARunner.java
/** * Gets the traceability./*from www .j av a 2 s .c o m*/ * * @return the traceability * @throws IllegalArgumentException the illegal argument exception * @throws RuntimeException the runtime exception */ public TraceabilityDocument getTraceability() throws IllegalArgumentException { if (designDecision == null || designDecision.isEmpty()) throw new IllegalArgumentException("designDecision can't be null or empty"); if (concerns == null || concerns.isEmpty()) throw new IllegalArgumentException("concerns can't be null or empty"); //create the documents to build the LSA Space //the document will contain a line for each concern and design decision File documentsFile; try { documentsFile = Utils.createFileFromStringList(Utils.sum(concerns, designDecision)); if (sspace == null) { try { sspace = File.createTempFile("lsa-" + concerns.hashCode() + designDecision.hashCode(), "-space.txt"); FileUtils.copyFile(documentsFile, this.sspace); logger.info("sspace = " + this.sspace.getAbsolutePath()); } catch (IOException e) { logger.error("Error creating the temporal file", e); } } } catch (IOException e) { throw new RuntimeException("Error creating the temporary file with the documents for the SSpace", e); } //build the LSA Space using the documents generated above File sspaceFile = null; try { sspaceFile = createLsaSpace(documentsFile); } catch (Exception e) { throw new RuntimeException("Error generating the SSpace", e); } //Measure the relation between concerns and design decisions //count the untraced and traced concerns TraceabilityDocument ret = null; try { ret = discoverTraceability(sspaceFile); } catch (Exception e) { throw new RuntimeException("Error discovering the traceability links", e); } //remove temporary files documentsFile.delete(); sspaceFile.delete(); return ret; }
From source file:hoot.services.controllers.ingest.FileUploadResourceTest.java
@Test @Category(UnitTest.class) public void TestBuildNativeRequestFgdbOgr() throws Exception { String jobId = "test-id-123"; String wkdirpath = homeFolder + "/upload/" + jobId; File workingDir = new File(wkdirpath); FileUtils.forceMkdir(workingDir);// w w w. j a v a2 s. co m org.junit.Assert.assertTrue(workingDir.exists()); File srcFile = new File(homeFolder + "/test-files/service/FileUploadResourceTest/fgdb_ogr.zip"); File destFile = new File(wkdirpath + "/fgdb_ogr.zip"); FileUtils.copyFile(srcFile, destFile); org.junit.Assert.assertTrue(destFile.exists()); FileUploadResource res = new FileUploadResource(); // Let's test zip JSONArray results = new JSONArray(); JSONObject zipStat = new JSONObject(); res._buildNativeRequest(jobId, "fgdb_ogr", "zip", "fgdb_ogr.zip", results, zipStat); org.junit.Assert.assertTrue(results.size() == 2); for (Object oRes : results) { JSONObject cnt = (JSONObject) oRes; if (cnt.get("type").toString().equals("FGDB_ZIP")) { org.junit.Assert.assertTrue(cnt.get("name").toString().equals("fgdb_ogr/DcGisRoads.gdb")); } else if (cnt.get("type").toString().equals("OGR_ZIP")) { org.junit.Assert .assertTrue(cnt.get("name").toString().equals("fgdb_ogr/jakarta_raya_coastline.shp")); } } FileUtils.forceDelete(workingDir); }
From source file:com.magnet.tools.tests.WebLogicStepDefs.java
public static void ensureBuildSuccessful(String filePath) { File logFile = new File(filePath); Assert.assertTrue(logFile + " should exist", logFile.exists() && logFile.isFile()); try {/* w w w. j av a 2 s.c om*/ FileInputStream fis = new FileInputStream(logFile); String content = IOUtils.toString(fis); File savedFile = new File(filePath + System.currentTimeMillis() + ".log"); FileUtils.copyFile(logFile, savedFile); Assert.assertTrue("build from log: " + savedFile.getAbsolutePath() + " should be successful", content.contains("BUILD SUCCESS")); Assert.assertFalse("build from log: " + savedFile.getAbsolutePath() + " should not fail", content.contains("BUILD FAILURE")); if (!savedFile.delete()) { ScenarioUtils.log("Couldn't delete " + savedFile); } // logFile.delete(); } catch (Exception e) { Assert.fail("An exception occurred: " + e); } }
From source file:FileTransferPackage.ConfigFileUpload.java
public String uploadTrustedACIssuerCert() { String path = getServletRequest().getSession().getServletContext().getRealPath("/"); File certFile = new File(path + "AA/Certs/Trusted_AC_Issuer_Certs/" + getTrustedIssuerFileFileName()); try {// w ww.j av a2 s . c o m FileUtils.copyFile(getTrustedIssuerFile(), certFile); } catch (IOException ex) { Logger.getLogger(ConfigFileUpload.class.getName()).log(Level.SEVERE, null, ex); } return SUCCESS; }
From source file:eu.apenet.dpt.standalone.gui.XsltAdderActionListener.java
private boolean saveXslt(File file) { try {//from ww w .j a va 2 s . c o m if (new File(Utilities.CONFIG_DIR + file.getName()).exists()) throw new Exception("XSL file already exists"); FileUtils.copyFile(file, new File(Utilities.CONFIG_DIR + file.getName())); return true; } catch (IOException e) { LOG.error("Moving file " + file.getAbsolutePath() + " failed", e); return false; } catch (Exception e) { return false; } }
From source file:com.sangupta.shire.site.SiteWriter.java
public void export(Resource resource) { // start the export process String path = createBasePath(resource); path = siteFolder.getAbsolutePath() + File.separator + path; File exportFile = new File(path); if (resource instanceof NonRenderableResource) { try {/*from w ww. j a v a2 s .c om*/ FileUtils.copyFile(resource.getFileHandle(), exportFile); } catch (IOException e) { e.printStackTrace(); } return; } if (resource instanceof GeneratedResource) { System.out.println("Exporting generated resource to: " + exportFile.getAbsolutePath()); try { FileUtils.writeStringToFile(exportFile, ((GeneratedResource) resource).getContent()); } catch (IOException e) { e.printStackTrace(); } } }
From source file:net.erdfelt.android.sdkfido.project.SourceCopier.java
private void recurseDirCopy(File basedir, File dir, Dir sourceDir, Dir resourceDir) throws IOException { String name, relpath;/* ww w . jav a2s . co m*/ System.out.print("."); for (File path : dir.listFiles()) { if (path.isDirectory()) { recurseDirCopy(basedir, path, sourceDir, resourceDir); } else if (path.isFile()) { relpath = PathUtil.toRelativePath(basedir, path); name = path.getName(); countCopied++; if (name.endsWith(".java") || name.endsWith(".aidl")) { if (javalisting.contains(relpath)) { countHits++; } else { countExtras++; } FileUtils.copyFile(path, sourceDir.getFile(relpath)); } else { countResources++; FileUtils.copyFile(path, resourceDir.getFile(relpath)); } } } }
From source file:co.cask.hydrator.plugin.batch.action.FileActionTestRun.java
/** * Method to copy test xml files into source folder path, from where test case read the file. *///from www.j a v a 2s. com @Before public void copyFiles() throws IOException { URL largeXMLUrl = this.getClass().getResource("/" + CATALOG_LARGE_XML_FILE_NAME); URL smallXMLUrl = this.getClass().getResource("/" + CATALOG_SMALL_XML_FILE_NAME); FileUtils.copyFile(new File(largeXMLUrl.getFile()), new File(sourceFolder, CATALOG_LARGE_XML_FILE_NAME)); FileUtils.copyFile(new File(smallXMLUrl.getFile()), new File(sourceFolder, CATALOG_SMALL_XML_FILE_NAME)); }