Example usage for org.apache.commons.io FileUtils copyFile

List of usage examples for org.apache.commons.io FileUtils copyFile

Introduction

In this page you can find the example usage for org.apache.commons.io FileUtils copyFile.

Prototype

public static void copyFile(File srcFile, File destFile) throws IOException 

Source Link

Document

Copies a file to a new location preserving the file date.

Usage

From source file:com.enioka.jqm.tools.ApiSimpleTest.java

@Before
public void before() throws IOException {
    Helpers.setSingleParam("disableWsApi", "false", em);
    Helpers.setSingleParam("enableWsApiAuth", "false", em);

    File jar = FileUtils.listFiles(new File("../jqm-ws/target/"), new String[] { "war" }, false).iterator()
            .next();/* w  w  w  . j  av  a  2s . co  m*/
    FileUtils.copyFile(jar, new File("./webapp/jqm-ws.war"));

    addAndStartEngine();
}

From source file:cx.jbzdak.diesIrae.genieConnector.ParamTest.java

@Before
public void startup() throws Exception {
    connector = new SimpleConnector();
    File f = new File("C:\\GENIE2K\\CAMFILES\\NBSSTD.CNF");
    File temp = File.createTempFile("gcTest", "CNF");
    temp.deleteOnExit();// www  . j  av a  2  s.  c  o m
    FileUtils.copyFile(f, temp);
    connector.setFlush(FlushType.AUTO_COMMIT);
    connector.openFile(temp, EnumSet.of(OpenMode.READ_WRITE, OpenMode.SYSTEM_WRITE, OpenMode.EXCLUSIVE,
            OpenMode.TAKE_CONTROL, OpenMode.TAKE_OVER));
    //connector.openSource("DET_1", EnumSet.of(OpenMode.READ_WRITE, OpenMode.SYSTEM_WRITE, OpenMode.EXCLUSIVE), SourceType.DETECTOR);
}

From source file:edu.umd.cs.guitar.util.Screenshotter.java

public void caputureScreen(WebDriver driver, String fileName) {
    if (!(driver instanceof TakesScreenshot)) {
        LOGGER.error("The web driver does not support screen capture!!!");
        return;//from  www  .ja  v a 2s  .co m
    }

    File scrFile = ((TakesScreenshot) driver).getScreenshotAs(OutputType.FILE);
    try {
        FileUtils.copyFile(scrFile, new File(fileName));
    } catch (IOException e) {
        e.printStackTrace();
    }

}

From source file:com.liferay.arquillian.maven.importer.LiferayPluginTestCase.java

protected static void setupPortalMinimal() {
    System.setProperty("liferay.version", LIFERAY_VERSION);

    System.setProperty("liferay.auto.deploy.dir", PORTAL_AUTO_DEPLOY_DIR);

    System.setProperty("liferay.app.server.deploy.dir", PORTAL_SERVER_DEPLOY_DIR);

    System.setProperty("liferay.app.server.lib.global.dir", PORTAL_SERVER_LIB_GLOBAL_DIR);

    System.setProperty("liferay.app.server.portal.dir", SERVER_PORTAL_DIR);

    try {/*from  ww w.j  a  va  2s .c o  m*/
        ArchiverManager archiverManager = plexusContainer.lookup(ArchiverManager.class);

        assertNotNull(archiverManager);

        FileUtils.forceMkdir(new File(PORTAL_AUTO_DEPLOY_DIR));
        FileUtils.forceMkdir(new File(PORTAL_SERVER_DEPLOY_DIR));
        FileUtils.forceMkdir(new File(PORTAL_SERVER_LIB_GLOBAL_DIR));
        FileUtils.forceMkdir(new File(SERVER_PORTAL_DIR));

        final MavenResolverSystem mavenResolverSystem = Maven.configureResolver()
                .fromClassloaderResource("settings.xml");

        File[] dependencies = mavenResolverSystem.loadPomFromClassLoaderResource("liferay-setup.xml")
                .importRuntimeAndTestDependencies().resolve().withoutTransitivity().asFile();

        File warFile = null;

        for (File file : dependencies) {
            String fileName = file.getName();
            String fileExtension = FilenameUtils.getExtension(fileName);

            if (fileExtension.equalsIgnoreCase("jar")) {
                FileUtils.copyFile(file, new File(PORTAL_SERVER_LIB_GLOBAL_DIR, file.getName()));
            } else if (fileExtension.equalsIgnoreCase("war") && fileName.contains("portal-web")) {

                warFile = file;
            }
        }

        assertNotNull(warFile);

        // extract portal war

        UnArchiver unArchiver = archiverManager.getUnArchiver(warFile);
        unArchiver.setDestDirectory(new File(SERVER_PORTAL_DIR));
        unArchiver.setSourceFile(warFile);
        unArchiver.setOverwrite(false);
        unArchiver.extract();
        setup = true;
    } catch (Exception e) {
        throw new RuntimeException(e);
    }
}

From source file:com.googlecode.t7mp.steps.resources.CopySetenvScriptStep.java

@Override
public void execute(Context context) {
    AbstractT7Mojo mojo = context.getMojo();
    File tomcatConfigDirectory = mojo.getTomcatConfigDirectory();
    if (tomcatConfigDirectory == null || !tomcatConfigDirectory.exists()) {
        return;/*from   ww w .  j a  v  a  2 s.co  m*/
    }
    File tomcatDirectory = tomcatConfigDirectory.getParentFile();
    File tomcatBinDirectory = new File(tomcatDirectory, "/bin/");
    File[] setEnvFiles = tomcatBinDirectory.listFiles(new FileFilter() {
        @Override
        public boolean accept(File file) {
            return (file.isFile() && file.getName().startsWith(PREFIX));
        }
    });
    // listFiles returns null if binDirectory does not exist
    // https://github.com/t7mp/t7mp/issues/28
    if (setEnvFiles != null) {
        for (File scriptFile : setEnvFiles) {
            try {
                FileUtils.copyFile(scriptFile,
                        new File(TomcatUtil.getBinDirectory(mojo.getCatalinaBase()), scriptFile.getName()));
            } catch (IOException e) {
                throw new TomcatSetupException(e.getMessage(), e);
            }
        }
    }
}

From source file:com.qait.automation.utils.TakeScreenshot.java

public void takeScreenshot() {
    screenshotPath = (getProperty("screenshot-path") != null) ? getProperty("screenshot-path") : screenshotPath;
    DateFormat dateFormat = new SimpleDateFormat("yyyy_MM_dd_hh_mm_a");
    Date date = new Date();
    String date_time = dateFormat.format(date);
    File file = new File(System.getProperty("user.dir") + File.separator + screenshotPath + File.separator
            + this.testname + File.separator + date_time);
    boolean exists = file.exists();
    if (!exists) {
        new File(System.getProperty("user.dir") + File.separator + screenshotPath + File.separator
                + this.testname + File.separator + date_time).mkdir();
    }//from  w w w  .  ja  v a 2s.  c o m

    File scrFile = ((TakesScreenshot) driver).getScreenshotAs(OutputType.FILE);
    try {
        String saveImgFile = System.getProperty("user.dir") + File.separator + screenshotPath + File.separator
                + this.testname + File.separator + date_time + File.separator + "screenshot.png";
        Reporter.log("Save Image File Path : " + saveImgFile, true);
        FileUtils.copyFile(scrFile, new File(saveImgFile));
    } catch (IOException e) {
        e.printStackTrace();
    }
}

From source file:com.moni.automation.utils.TakeScreenshot.java

public void takeScreenshot() {
    screenshotPath = (getProperty("screenshot-path") != null) ? getProperty("screenshot-path") : screenshotPath;
    DateFormat dateFormat = new SimpleDateFormat("yyyy_MM_dd_hh_mm_a");
    Date date = new Date();
    String date_time = dateFormat.format(date);
    File file = new File(System.getProperty("user.dir") + File.separator + screenshotPath + File.separator
            + this.testname + File.separator + date_time);
    boolean exists = file.exists();
    if (!exists) {
        new File(System.getProperty("user.dir") + File.separator + screenshotPath + File.separator
                + this.testname + File.separator + date_time).mkdir();
    }/*w  ww  . j av  a  2  s .  co  m*/

    File scrFile = ((TakesScreenshot) driver).getScreenshotAs(OutputType.FILE);
    try {
        String saveImgFile = System.getProperty("user.dir") + File.separator + screenshotPath + File.separator
                + this.testname + File.separator + date_time + File.separator + "screenshot.png";
        Reporter.log("[INFO]: Save Image File Path : " + saveImgFile, true);
        FileUtils.copyFile(scrFile, new File(saveImgFile));
    } catch (IOException e) {
        e.printStackTrace();
    }
}

From source file:net.jsign.PESignerTaskTest.java

protected void setUp() throws Exception {
    project = new Project();
    project.setCoreLoader(getClass().getClassLoader());
    project.init();/* w  w  w .  j  av a2 s  . co  m*/

    File buildFile = new File("target/test-classes/testbuild.xml");
    project.setBaseDir(buildFile.getParentFile());

    final ProjectHelper helper = ProjectHelper.getProjectHelper();
    helper.parse(project, buildFile);

    File sourceFile = new File("target/test-classes/wineyes.exe");
    File targetFile = new File("target/test-classes/wineyes-signed-with-ant.exe");

    // remove the files signed previously
    if (targetFile.exists()) {
        assertTrue("Unable to remove the previously signed file", targetFile.delete());
    }

    FileUtils.copyFile(sourceFile, targetFile);

    redirectOutput(System.out);
}

From source file:net.alteiar.utils.file.SerializableFile.java

public SerializableFile(File file) throws IOException {
    id = new UniqueID();

    String campaignDir = CampaignClient.getInstance().getCampaignDirectory();
    String filename = FILE_DIR + "/" + DocumentIO.validateFilename(id.toString());
    FileUtils.copyFile(file, new File(campaignDir, filename));
}

From source file:integration.BfPixelBufferTest.java

private void setUpTestFile(String fileName) throws Throwable, NoSuchAlgorithmException {
    File srcFile = ResourceUtils.getFile("classpath:" + fileName);
    String dataDirName = root.getSession().getConfigService().getConfigValue("omero.data.dir");
    String destPathName = UUID.randomUUID().toString();
    File dataDir = new File(dataDirName);
    destPath = new File(dataDir, destPathName);
    File destFile = new File(destPath, fileName);
    destPath.mkdir();/*from w w  w. java 2 s .  com*/

    // Copy file into repo
    FileUtils.copyFile(srcFile, destFile);
    // Import file
    List<Pixels> pixList = importFile(srcFile, fileName);
    log.debug(String.format("Imported: %s, pixid: %d", srcFile, pixList.get(0).getId().getValue()));

    // Access the imported pixels via a RawPixelsStore
    rps = factory.createRawPixelsStore();
    rps.setPixelsId(pixList.get(0).getId().getValue(), false);

    // Access the data from file via BfPixelBuffer
    destFileName = destFile.getCanonicalPath();
    bf = new BfPixelBuffer(destFileName, new ImageReader());
}