List of usage examples for org.apache.commons.io FileUtils copyFile
public static void copyFile(File srcFile, File destFile) throws IOException
From source file:net.ageto.gyrex.impex.common.steps.impl.copy.FileCopyToDirectory.java
@Override protected StatusStep process() { try {/*w w w . ja v a2s.com*/ String sourceFilename = (String) getInputParam( FileCopyToDirectoryDefinition.InputParamNames.SOURCE_FILENAME.name()); File sourceFile = new File(sourceFilename); if (!sourceFile.isFile()) { processError("The source is not a valid file."); return StatusStep.ERROR; } String destinationFilename = (String) getInputParam( FileCopyToDirectoryDefinition.OutputParamNames.DESTINATION_FILENAME.name()); File destinationFile = new File(destinationFilename); // copy file FileUtils.copyFile(sourceFile, destinationFile); } catch (IOException e) { processError("File could not be created."); } processInfo("{0} has been completed successfully.", ID); return StatusStep.OK; }
From source file:com.kylinolap.common.util.CliCommandExecutor.java
private void copyNative(String localFile, String destDir) throws IOException { File src = new File(localFile); File dest = new File(destDir, src.getName()); FileUtils.copyFile(src, dest); }
From source file:ch.unibas.fittingwizard.mocks.MockLRAScript.java
@Override public LRAScriptOutput execute(LRAScriptInput input) { // /esp-fit.pc-mtp/src/calc_LRA.py -in co2 // This generates a *_l.pun file. String moleculeName = getMoleculeName(input.getSdfFile()); File specificMoleculeDir = new File(moleculesDir, moleculeName); File lpunOutputFile = new File(specificMoleculeDir, moleculeName + lpunExtension); File precomputedDataDir = new File(testMoleculesDir, moleculeName); for (String fileExtension : filesToCopy) { File precomputedFile = new File(precomputedDataDir, moleculeName + fileExtension); try {/* ww w .j a v a2 s .com*/ FileUtils.copyFile(precomputedFile, new File(specificMoleculeDir, moleculeName + fileExtension)); } catch (IOException e) { logger.error("Could not copy precomputed file " + precomputedFile); throw new RuntimeException("Could not copy precomputed file " + precomputedFile); } } return new LRAScriptOutput(lpunOutputFile); }
From source file:com.ibm.watson.movieapp.dialog.fvt.config.TestWatcherRule.java
@Override protected void failed(Throwable e, Description description) { TakesScreenshot takesScreenshot = (TakesScreenshot) browser; File scrFile = takesScreenshot.getScreenshotAs(OutputType.FILE); File destFile = getDestinationFile(description.getMethodName()); try {/*from ww w .j a va2 s. c om*/ FileUtils.copyFile(scrFile, destFile); } catch (IOException ioe) { throw new RuntimeException(ioe); } }
From source file:com.arksoft.epamms.EpammsEbTests.java
/** * Called at the beginning of the test to reset the DB. */// ww w. j av a2s . c o m @BeforeClass public static void resetDB() throws IOException { // 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.wavemaker.commons.util.utils.ClassLoaderUtilsTest.java
@Test public void tempClassLoader_getResourceTest() throws Exception { File sourceJar = new ClassPathResource("com/wavemaker/commons/foojar.jar").getFile(); File jar = File.createTempFile("tempClassLoader_getClassTest", ".jar"); jar.deleteOnExit();/*from w ww . ja v a2 s. c o m*/ FileUtils.copyFile(sourceJar, jar); try { ClassLoader cl = ClassLoaderUtils.getTempClassLoaderForFile(jar); InputStream is = ClassLoaderUtils.getResourceAsStream("foo/bar/baz/JarType.java", cl); assertNotNull(is); assertTrue(is.available() > 0); is.close(); } finally { jar.delete(); } }
From source file:io.uploader.drive.config.ConfigTest.java
@Before public void init() throws IOException { // generate the test config file File template = new File( new ConfigTest().getClass().getResource("/driveuploader-settings-test.xml").getFile()); configSettingFile = tmpFolder.newFile(); FileUtils.copyFile(template, configSettingFile); assertFalse(configSettingFile == null); assertTrue(io.uploader.drive.util.FileUtils.getFileAttr(Paths.get(configSettingFile.getPath())).size() > 0); // Check the default values before loading if (!hasConfigBeenLoaded) { assertTrue(80 == Configuration.INSTANCE.getHttpProxySettings().getPort()); assertTrue(443 == Configuration.INSTANCE.getHttpsProxySettings().getPort()); }//w ww. jav a 2 s.c om // load the test settings try { Configuration.INSTANCE.load(configSettingFile.getPath()); hasConfigBeenLoaded = true; } catch (ConfigurationException e) { logger.error("Error occurred while loading the cinfiguration file", e); assertTrue(false); } }
From source file:mx.redhat.jbpm.CustomType.FileStorageServiceImpl.java
@Override public String saveFile(String fieldName, File file) { try {/*www .j a v a 2 s . c om*/ String destinationPath = generateUniquePath(fieldName, file.getName()); File destination = new File(destinationPath); FileUtils.copyFile(file, destination); return destinationPath; } catch (Exception ex) { } return null; }
From source file:com.manning.siia.kitchen.RecipeReadingTest.java
@Test public void shouldReadFileInDirectoryToMessage() throws IOException { File resource = new ClassPathResource("/pilav.xml").getFile(); //copy// w w w. j a v a2 s .co m File recipeWriting = recipeBookLocation.newFile("pilav.xml.writing"); FileUtils.copyFile(resource, recipeWriting); //then rename final File outFile = recipeBookLocation.newFile("pilav.xml"); recipeWriting.renameTo(outFile); final Message<File> message = (Message<File>) test.receive(2000); assertThat(message, is(notNullValue())); final File payload = message.getPayload(); assertThat(payload.getPath(), is(outFile.getPath())); }
From source file:models.ChatRoom.java
public void checkPicture(String nick) { // Use the name of the nickname for the picture as well File file = Play.getFile("/data/" + nick + "-thumb.png"); // If picture is not specified, use a default one. if (!file.exists()) { int number = (new Random().nextInt(12) + 1); file = Play.getFile("/public/images/" + number + ".png"); File dest = Play.getFile("/data/" + nick + "-thumb.png"); try {//from w w w . j a v a 2 s.c o m FileUtils.copyFile(file, dest); } catch (Exception e) { e.printStackTrace(); } } }