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.genericdemo.enginedata.Tester.java
@Test public void blah() throws MalformedURLException, IOException { URL schemaURL = new URL( "file:/Users/ashwin/code/generic/genericdemo/target/genericdemo-1.0-SNAPSHOT.jar!/engineDataEventSchema.json"); URL localSchemaURL = new URL("file:///tmp/blah.txt"); FileUtils.deleteQuietly(new File(localSchemaURL.getPath())); FileUtils.copyFile(new File(schemaURL.getPath()), new File(localSchemaURL.getPath())); Path schemaPath = new Path(schemaURL.toString()); Path localPath = new Path(localSchemaURL.toString()); System.out.println("jar $$$ = " + schemaPath); System.out.println("local $$$ = " + localPath); }
From source file:hrider.io.FileHelper.java
public static void copy(File source, File target) throws IOException { FileUtils.copyFile(source, target); }
From source file:it.geosolutions.jaiext.JAIEXTInitializationTest.java
@BeforeClass public static void setup() throws FileNotFoundException, IOException { final File inputJAIFile = TestData.file(JAIEXTInitializationTest.class, "META-INF" + File.separator + "registryFile2.jaiext"); newJAIFile = new File(inputJAIFile.getParentFile().getParentFile().getParentFile().getParentFile() .getParentFile().getParentFile(), "META-INF" + File.separator + "registryFile.jaiext"); FileUtils.copyFile(inputJAIFile, newJAIFile); }
From source file:edu.harvard.hul.ois.fits.junit.AudioStdSchemaTestXmlUnit_NoMD5.java
@AfterClass public static void tearDownAfterClass() throws Exception { System.out.println("Resetting fits.xml"); // Set the backup to the original fits.xml FileUtils.copyFile(FileUtils.getFile("xml/fits_back.xml"), FileUtils.getFile("xml/fits.xml")); // Remove the temp file FileUtils.deleteQuietly(FileUtils.getFile("xml/fits_back.xml")); }
From source file:com.r573.enfili.common.io.file.FileHelper.java
public static void copyAllFilesInFolder(File srcFolder, File destFolder) { try {// w w w.j a va2 s .com if (!srcFolder.exists()) { // TODO: ignore for now. Figure out the appropriate error // handling for this later return; } Collection<File> files = FileUtils.listFiles(srcFolder, null, true); for (File file : files) { File destFile = new PathBuilder(destFolder.getPath()).append(file.getName()).toFile(); FileUtils.copyFile(file, destFile); } } catch (IOException e) { throw new FileOpException(e); } }
From source file:localSPs.SpiderOakAPI.java
public static void uploadFile(String fileName) throws IOException { java.io.File file = new java.io.File(UPLOAD_PATH + fileName); String newDir = ROOT_PATH;//from w ww .j a v a 2 s. c om java.io.File newFile = new java.io.File(newDir + fileName); FileUtils.copyFile(file, newFile); }
From source file:net.refractions.udig.document.model.FileAttachmentDocument.java
@Override public boolean saveAs(File newfile) { try {/*from w w w .j ava2 s .c om*/ FileUtils.copyFile(file, newfile); return true; } catch (IOException e) { e.printStackTrace(); } return false; }
From source file:com.dhenton9000.selenium.generic.UtilMethods.java
/** * include full file name/path// w w w .j a va2s.c om * @param fileName * @param driver */ public static void takeScreenshot(String fileName, WebDriver driver) { try { String date = Long.toString(new Date().getTime()); File pngFile = new File(fileName + date + ".png"); File scrFile = ((TakesScreenshot) driver).getScreenshotAs(OutputType.FILE); FileUtils.copyFile(scrFile, pngFile); } catch (WebDriverException e) { LOG.error("webdriver problem with screenshot: " + " " + e.getMessage()); } catch (IOException e) { LOG.error("io problem with screenshot: " + " " + e.getMessage()); } }
From source file:com.sap.prd.mobile.ios.mios.FileCopyProjectModifier.java
@Override void execute() throws Exception { FileUtils.copyFile(new File(alternateTestSourceDirectory, path), new File(testExecutionDirectory, path)); }
From source file:app.admin.career.DoUploadImgCareerActionSupport.java
public String execute() throws Exception { String destPath = "D:/hoctap/SEM4/ProjectSem4Strut2/web/images/career"; DataProcess dataProcess = new DataProcess(); String url = ""; try {//ww w .j a v a 2 s. com Random rand = new Random(); int ran = rand.nextInt(); url = Integer.toString(ran) + ".jpg"; File destFile = new File(destPath, url); FileUtils.copyFile(file, destFile); } catch (IOException e) { return "error"; } url = "images/career/" + url; CareerJson careerJson = new CareerJson(); List<CareerForJson> careerForJsons = careerJson.read(); for (CareerForJson careerForJson : careerForJsons) { if (careerForJson.getCode().equals(code)) { careerForJsons.remove(careerForJson); careerForJson.setImage(url); careerForJsons.add(careerForJson); break; } } careerJson.write(careerForJsons); // if(dataProcess.setAvata(codeWorker, url)) // return "index"; // return "error"; return "admin"; }