List of usage examples for org.apache.commons.io FileUtils copyFile
public static void copyFile(File srcFile, File destFile) throws IOException
From source file:com.tascape.qa.th.webui.driver.WebApp.java
public File takeScreenshot() { long start = System.currentTimeMillis(); LOG.debug("Take screenshot"); try {/*w w w. j ava 2s .co m*/ File png = this.saveIntoFile("ss", "png", ""); File f = webBrowser.takeBrowerScreenshot(); FileUtils.copyFile(f, png); LOG.trace("time {} ms", System.currentTimeMillis() - start); return png; } catch (IOException ex) { throw new WebUiException("Cannot take screenshot", ex); } }
From source file:com.diffplug.gradle.CmdLine.java
/** Removes the given file or directory. */ public void copy(File src, File dst) { run(() -> {/* w ww . j a v a 2s . com*/ if (!src.exists()) { throw new IllegalArgumentException("copy failed: " + src.getAbsolutePath() + " does not exist."); } if (src.isDirectory()) { FileUtils.copyDirectory(src, dst); } else { FileUtils.copyFile(src, dst); } }); }
From source file:com.intbit.PhantomImageConverter.java
public File getImage(String htmlString, JSONArray json_font_list, String width, String height, String x, String y) throws Exception { File createdHtmlFile = tempHTML(htmlString, json_font_list); File createdJSFile = tempJS(createdHtmlFile, width, height, x, y); Runtime runTime = Runtime.getRuntime(); String execPath = "phantomjs " + createdJSFile.getPath(); //String execPath = "/Users/AR/Downloads/DevSoftware/PhantomJS/phantomjs " + createdJSFile.getPath(); Process process = runTime.exec(execPath); int exitStatus = process.waitFor(); File tempImagePath = new File(tempPath + File.separator + createdJSFile.getName().replace("js", "png")); logger.info(tempImagePath.getPath()); File fileToSend = tempImagePath; if (!StringUtil.isEmpty(this.outputFilePath)) { File outputFile = new File(outputFilePath + File.separator + tempImagePath.getName()); FileUtils.copyFile(tempImagePath, outputFile); fileToSend = outputFile;//from www .j a v a 2 s . co m tempImagePath.delete(); } createdHtmlFile.delete(); createdJSFile.delete(); return fileToSend; }
From source file:com.fizzed.stork.maven.AssemblyMojo.java
@Override public void execute() throws MojoExecutionException, MojoFailureException { if (!stageDirectory.exists()) { getLog().info("Creating stage directory: " + stageDirectory); stageDirectory.mkdirs();//ww w . j a v a 2 s .com } try { List<Artifact> artifacts = artifactsToStage(); // // copy runtime dependencies to stage directory... // File stageLibDir = new File(stageDirectory, "lib"); // directly pulled from maven Project.java (how it returns the getRuntimeClasspathElements() value) for (Artifact a : artifacts) { File f = a.getFile(); if (f == null) { getLog().error("Project artifact was null (maybe not compiled into jar yet?)"); } else { // generate final jar name (which appends groupId) String artifactName = a.getGroupId() + "." + a.getArtifactId() + "-" + a.getVersion() + ".jar"; File stageArtificateFile = new File(stageLibDir, artifactName); FileUtils.copyFile(f, stageArtificateFile); } } // copy conf, bin, and share dirs File binDir = new File(project.getBasedir(), "bin"); if (binDir.exists()) { File stageBinDir = new File(stageDirectory, "bin"); FileUtils.copyDirectory(binDir, stageBinDir); } File confDir = new File(project.getBasedir(), "conf"); if (confDir.exists()) { File stageConfDir = new File(stageDirectory, "conf"); FileUtils.copyDirectory(confDir, stageConfDir); } File shareDir = new File(project.getBasedir(), "share"); if (shareDir.exists()) { File stageShareDir = new File(stageDirectory, "share"); FileUtils.copyDirectory(shareDir, stageShareDir); } // copy standard project resources (e.g. readme*, license*, changelog*, release* files) AssemblyUtils.copyStandardProjectResources(project.getBasedir(), stageDirectory); // tarball it up File tgzFile = AssemblyUtils.createTGZ(outputDirectory, stageDirectory, finalName); getLog().info("Generated maven stork assembly: " + tgzFile); } catch (Exception e) { throw new MojoExecutionException(e.getMessage(), e); } }
From source file:de.uzk.hki.da.grid.FakeGridFacade.java
@Override public void get(File destination, String sourceFileAdress) throws IOException { if (!sourceFileAdress.startsWith(C.FS_SEPARATOR)) sourceFileAdress = C.FS_SEPARATOR + sourceFileAdress; String source = getGridCacheAreaRootPath() + WorkArea.AIP + sourceFileAdress; logger.debug("Retrieving: " + source + " to " + destination); FileUtils.copyFile(new File(source), destination); }
From source file:com.keybox.manage.action.UploadAndPushAction.java
@Action(value = "/admin/upload", results = { @Result(name = "input", location = "/admin/upload.jsp"), @Result(name = "success", location = "/admin/upload_result.jsp") }) public String upload() { Long userId = AuthUtil.getUserId(servletRequest.getSession()); try {/*from w ww . j ava 2 s. c o m*/ File destination = new File(UPLOAD_PATH, uploadFileName); FileUtils.copyFile(upload, destination); pendingSystemStatus = SystemStatusDB.getNextPendingSystem(userId); hostSystemList = SystemStatusDB.getAllSystemStatus(userId); } catch (Exception e) { log.error(e.toString(), e); return INPUT; } return SUCCESS; }
From source file:com.galenframework.tests.runner.GalenConfigTest.java
@Test public void shouldRead_configFile_fromSpecifiedLocation() throws IOException { File configFile = new File("config2"); configFile.createNewFile();//from w w w.j a v a 2 s. co m FileUtils.copyFile(new File(getClass().getResource("/config2").getFile()), configFile); System.setProperty("galen.config.file", "config2"); GalenConfig config = GalenConfig.getConfig(); config.reset(); MatcherAssert.assertThat(config.getRangeApproximation(), is(12345)); }
From source file:com.gs.obevo.util.FileUtilsCobra.java
public static void copyFile(File srcFile, File destFile) { try {//w w w. j a v a2s . co m FileUtils.copyFile(srcFile, destFile); } catch (IOException e) { throw new RuntimeException(e); } }
From source file:com.vamonossoftware.core.ArchiveServiceSimpleImpl.java
/** * Puts the given file into the archive directory, using a MOVE or COPY based on the constructor parameter 'move'. *//* w w w . j ava 2s . c o m*/ public synchronized File archive(File file) { File basePath = new File(archiveDir, FastDateFormat.getInstance(pathPattern).format(new DateTime().toDate())); int count = 1; File path = null; do { path = new File(basePath, Integer.toString(count)); count++; } while (path.exists()); path.mkdirs(); File destFile = new File(path, file.getName()); try { if (move) { FileUtils.moveFile(file, destFile); } else { FileUtils.copyFile(file, destFile); } return destFile; } catch (IOException ex) { throw new RuntimeException(ex); } }
From source file:com.constellio.app.services.appManagement.AppManagementServicesAcceptanceTest.java
@Before public void setup() throws IOException { webappsFolder = newTempFolder();/* w w w.j a v a2 s.c om*/ final File currentConstellioFolder = new File(webappsFolder, "webapp-5.0.5"); currentConstellioFolder.mkdirs(); commandFile = new File(newTempFolder(), "cmd"); uploadWarFile = new File(newTempFolder(), "upload.war"); wrapperConf = new File(newTempFolder(), "wrapper.conf"); pluginsFolder = newTempFolder(); FileUtils.copyFile(getTestResourceFile("initial-wrapper.conf"), wrapperConf); SystemGlobalConfigsManager systemGlobalConfigsManager = getAppLayerFactory() .getSystemGlobalConfigsManager(); getAppLayerFactory().getModelLayerFactory().getSystemConfigurationsManager() .setValue(ConstellioEIMConfigs.CLEAN_DURING_INSTALL, true); foldersLocator = new FoldersLocator() { @Override public File getConstellioWebappFolder() { return currentConstellioFolder; } @Override public File getWrapperCommandFile() { return commandFile; } @Override public File getWrapperConf() { return wrapperConf; } @Override public File getUploadConstellioWarFile() { return uploadWarFile; } @Override public File getPluginsJarsFolder() { return pluginsFolder; } }; AppLayerFactory appLayerFactory = spy(getAppLayerFactory()); when(appLayerFactory.getPluginManager()).thenReturn(pluginManager); appManagementService = spy(new AppManagementService(appLayerFactory, foldersLocator)); doReturn("5.0.4").when(appManagementService).getWarVersion(); }