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.fmb.common.LogTools.java
public static String screenShot(BrowserEmulator be) { // String dir = "screenshot"; // TODO String dir = "target/publish-report"; //?screenshot String time = new SimpleDateFormat("yyyyMMdd-HHmmss").format(new Date()); String screenShotPath = dir + File.separator + time + ".png"; WebDriver augmentedDriver = null;/*from w ww .j a va 2s .c o m*/ if (GlobalSettings.browserCoreType == 1 || GlobalSettings.browserCoreType == 3) { augmentedDriver = be.getBrowserCore(); augmentedDriver.manage().window().setPosition(new Point(0, 0)); augmentedDriver.manage().window().setSize(new Dimension(9999, 9999)); } else if (GlobalSettings.browserCoreType == 2) { augmentedDriver = new Augmenter().augment(be.getBrowserCore()); } else { return "Incorrect browser type"; } try { File sourceFile = ((TakesScreenshot) augmentedDriver).getScreenshotAs(OutputType.FILE); FileUtils.copyFile(sourceFile, new File(screenShotPath)); } catch (Exception e) { e.printStackTrace(); return "Failed to screenshot"; } // Convert '\' into '/' for web image browsing. return screenShotPath.replace("\\", "/"); }
From source file:co.com.sigemco.alfa.admin.logica.LogoLogica.java
/** * Funcion con la cual guardo la imagen en el repositorio de imagenes * @return /*from w ww . j a va 2s. c o m*/ */ public String guardaImagenRepositorio(File file) { String rta = "Ok"; try { File nuevoArchivo = new File(this.rutaBase + "logo.jpg"); FileUtils.copyFile(file, nuevoArchivo); } catch (Exception e) { e.printStackTrace(); rta = "Error " + e; } return rta; }
From source file:ZipUtilInPlaceTest.java
public void testAddEntry() throws IOException { File src = new File(getClass().getResource("demo.zip").getPath()); File dest = File.createTempFile("temp.zip", null); try {/*from w w w. j ava2 s .c om*/ FileUtils.copyFile(src, dest); final String fileName = "TestFile.txt"; assertFalse(ZipUtil.containsEntry(dest, fileName)); File newEntry = new File(getClass().getResource(fileName).getPath()); ZipUtil.addEntry(dest, fileName, newEntry); assertTrue(ZipUtil.containsEntry(dest, fileName)); } finally { FileUtils.deleteQuietly(dest); } }
From source file:com.enioka.jqm.tools.DeliverableTest.java
@Before public void before() throws IOException { File jar = FileUtils.listFiles(new File("../jqm-ws/target/"), new String[] { "war" }, false).iterator() .next();//w w w. j ava 2 s . co m FileUtils.copyFile(jar, new File("./webapp/jqm-ws.war")); }
From source file:ch.unibas.fittingwizard.mocks.MockExportScript.java
@Override public ExportScriptOutput execute(ExportScriptInput input) { File outputDir = new File(sessionDir, RealFitScript.OutputDirName); // working directory is output directory String testFile = "co2fit.lpun"; File testdata = new File(new File(testdataDir, RealFitScript.OutputDirName), testFile); File outputFile = new File(outputDir, testFile); try {/*from ww w .j av a 2s .c o m*/ FileUtils.copyFile(testdata, outputFile); } catch (IOException e) { throw new RuntimeException("Could not copy testdata to ouptut dir.", e); } return new ExportScriptOutput(outputFile); }
From source file:de.uzk.hki.da.at.ATIngestValidation.java
@BeforeClass public static void putPackages() throws IOException { ath.putAIPToLongTermStorage(IDENTIFIER, ORIG_NAME, null, 100); FileUtils.copyFile(Path.makeFile(TC.TEST_ROOT_AT, CONTAINER_NAME), Path.makeFile(localNode.getIngestAreaRootPath(), testContractor.getUsername(), CONTAINER_NAME)); ath.putSIPtoIngestArea(ORIG_NAME, "tgz", ORIG_NAME); ath.putSIPtoIngestArea(AT_ERSTE_ZEILE_TAGMANIFEST1_ZEICHENGEAENDERT, "tgz", AT_ERSTE_ZEILE_TAGMANIFEST1_ZEICHENGEAENDERT); ath.putSIPtoIngestArea(AT_MANIFEST_MD5_2FILESGEAENDERT, "tgz", AT_MANIFEST_MD5_2FILESGEAENDERT); ath.putSIPtoIngestArea(AT_EINE_DATEI_GELOESCHT, "tgz", AT_EINE_DATEI_GELOESCHT); ath.putSIPtoIngestArea(AT_INVALID_PREMIS, "zip", AT_INVALID_PREMIS); ath.putSIPtoIngestArea(AT_DUPLICATE_METADATA_FILES, "tgz", AT_DUPLICATE_METADATA_FILES); ath.putSIPtoIngestArea(AT_DUPLICATE_DOCUMENT_NAME, "tgz", AT_DUPLICATE_DOCUMENT_NAME); }
From source file:jp.co.opentone.bsol.linkbinder.view.logo.ProjectLogoManagerTest.java
public static void createLogoFiles() throws Exception { // ??/*from w ww. j a v a 2s . c o m*/ FileUtils.copyFile(testLogo, new File("/tmp/test-default.png")); FileUtils.copyFile(testLogo, new File("/tmp/test-project.png")); }
From source file:com.googlecode.t7mp.steps.CopyJuliJarStep.java
@Override public void execute(Context context) { try {/*w w w . j av a 2s.co m*/ File juliJarFileSource = new File( TomcatUtil.getBinDirectory(context.getConfiguration().getCatalinaBase()), JAR_NAME); File juliJarFileDestination = new File( TomcatUtil.getLibDirectory(context.getConfiguration().getCatalinaBase()), JAR_NAME); FileUtils.copyFile(juliJarFileSource, juliJarFileDestination); } catch (IOException e) { throw new TomcatSetupException(e.getMessage(), e); } }
From source file:de.akra.idocit.wsdl.services.WSDLParserTest.java
@BeforeClass public static void init() throws IOException { // copy the XSD to the out folder because the WSDL needs it there FileUtils.copyFile(new File(XML_SCHEMA_FILE_NAME), new File(TMP_XML_SCHEMA_FILE_NAME)); }
From source file:gov.nih.nci.calims2.business.storage.StorageServiceImpl.java
/** * {@inheritDoc}/*from w w w . j a v a 2 s . c o m*/ * * @throws StorageServiceException */ public Document save(File file) throws StorageServiceException { File dir = new File(filesystemrootdir); File outputFile = null; try { outputFile = File.createTempFile("LPGLIMS", "", dir); FileUtils.copyFile(file, outputFile); } catch (IOException e) { throw new StorageServiceException("Error saving file from storage" + e.getMessage()); } Document document = new Document(); document.setUniversalResourceLocator(outputFile.getAbsolutePath()); return document; }