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.codenvy.corp.MainPage.java

public void gotoManageViewAndGoToIdeBornDown() throws IOException, InterruptedException {
    driver.get(String.format(mangeViewUrlIDE, agileIdIDE));
    new WebDriverWait(driver, 10).until(ExpectedConditions.visibilityOf(burnDownMAinContainer));
    burnDownNameIDE = new WebDriverWait(driver, 10)
            .until(ExpectedConditions.visibilityOfElementLocated(By.id("ghx-items-trigger"))).getText();
    Thread.sleep(10000);/*from  w ww.java  2  s  .  c  om*/
    File screen = ((TakesScreenshot) driver).getScreenshotAs(OutputType.FILE);
    Point p = burnDownMAinContainer.getLocation();

    int width = burnDownMAinContainer.getSize().getWidth();
    int height = burnDownMAinContainer.getSize().getHeight();

    BufferedImage img = ImageIO.read(screen);

    BufferedImage dest = img.getSubimage(p.getX(), p.getY() - 50, width, height);

    ImageIO.write(dest, "png", screen);
    File file = new File(burnDownNameIDE + ".png");
    FileUtils.copyFile(screen, file);
    addText(file, burnDownNameIDE);
}

From source file:com.redhat.rcm.version.util.PomUtilsTest.java

@Test
public void pomRewriteInjectsXMLDeclaration() throws Exception {
    final File srcPom = getResourceFile(BASE + "no-xml-declaration.pom");

    final File pom = new File(repo, srcPom.getName());
    FileUtils.copyFile(srcPom, pom);

    final String orig = readFileToString(pom);
    assertThat(orig.contains("<?xml version=\"1.0\" encoding=\"UTF-8\"?>"), equalTo(false));

    final Model model = loadModel(pom);

    final VersionManagerSession session = newVersionManagerSession(workspace, reports, null);
    final File out = PomUtils.writeModifiedPom(model, pom, new FullProjectKey(model), model.getVersion(),
            pom.getParentFile(), session, false);

    assertNoErrors(session);/*from w  w  w.j  a v a 2 s .com*/
    final String pomStr = readFileToString(out);
    System.out.println("Modified POM for " + name.getMethodName() + ":\n\n" + pomStr + "\n\n");
    assertThat(pomStr.contains("<?xml version=\"1.0\" encoding=\"UTF-8\"?>"), equalTo(true));

    loadModel(out);
}

From source file:com.stratio.decision.service.SolrOperationsService.java

public void createSolrConfig(String confPath) throws URISyntaxException, IOException {
    FileUtils.copyFile(new File(ClassLoader.getSystemResource("./solr-config/solrconfig.xml").toURI()),
            new File(confPath + "/solrconfig.xml"));
}

From source file:be.vds.jtbdive.core.utils.FileUtilities.java

public static void copy(File srcFile, File destFile) throws IOException {
    FileUtils.copyFile(srcFile, destFile);
}

From source file:io.selendroid.standalone.builder.SelendroidServerBuilderTest.java

@Test
public void testShouldBeAbleToResignAnSignedApp() throws Exception {
    SelendroidServerBuilder builder = getDefaultBuilder();
    File androidApp = File.createTempFile("testapp", ".apk");
    FileUtils.copyFile(new File(APK_FILE), androidApp);

    AndroidApp resignedApp = builder.resignApp(androidApp);
    assertResignedApp(resignedApp, androidApp);

    // Verify that apk is signed
    CommandLine cmd = new CommandLine(AndroidSdk.aapt());
    cmd.addArgument("list", false);
    cmd.addArgument(resignedApp.getAbsolutePath(), false);

    String output = ShellCommand.exec(cmd);

    assertResultDoesNotContainFile(output, "META-INF/CERT.RSA");
    assertResultDoesNotContainFile(output, "META-INF/CERT.SF");
    assertResultDoesContainFile(output, "META-INF/ANDROIDD.SF");
    assertResultDoesContainFile(output, "META-INF/ANDROIDD.RSA");
    assertResultDoesContainFile(output, "AndroidManifest.xml");
}

From source file:ml.shifu.shifu.core.pmml.PMMLTranslatorTest.java

@Test
public void testMixTypeVariablePmmlCase() throws Exception {
    // Step 1. Eval the scores using SHIFU
    File originModel = new File("src/test/resources/example/labor-neg/DataStore/DataSet1/ModelConfig.json");
    File tmpModel = new File("ModelConfig.json");

    File originColumn = new File("src/test/resources/example/labor-neg/DataStore/DataSet1/ColumnConfig.json");
    File tmpColumn = new File("ColumnConfig.json");

    File modelsDir = new File("src/test/resources/example/labor-neg/DataStore/DataSet1/models");
    File tmpModelsDir = new File("models");

    FileUtils.copyFile(originModel, tmpModel);
    FileUtils.copyFile(originColumn, tmpColumn);
    FileUtils.copyDirectory(modelsDir, tmpModelsDir);

    // run evaluation set
    ShifuCLI.runEvalScore("EvalA");
    File evalScore = new File("evals/EvalA/EvalScore");

    ShifuCLI.exportModel(null);/*from  w w w  .j a v  a 2s . co m*/

    // Step 2. Eval the scores using PMML
    String pmmlPath = "pmmls/ModelK0.pmml";
    String DataPath = "src/test/resources/example/labor-neg/DataStore/DataSet1/data.dat";
    String OutPath = "model_k_out.dat";
    evalPmml(pmmlPath, DataPath, OutPath, ",", "model0");

    // Step 3. Compare the SHIFU Eval score and PMML score
    compareScore(evalScore, new File(OutPath), "model0", "\\|", 1.0);
    FileUtils.deleteQuietly(new File(OutPath));

    FileUtils.deleteQuietly(tmpModel);
    FileUtils.deleteQuietly(tmpColumn);
    FileUtils.deleteDirectory(tmpModelsDir);

    FileUtils.deleteQuietly(new File("./pmmls"));
    FileUtils.deleteQuietly(new File("evals"));
}

From source file:di.uniba.it.tri.aan.AAN2file.java

public void build(String anndirname, String outputdirname) throws Exception {
    for (int i = 0; i < yearsdir.length; i++) {
        File metadatafile = new File(anndirname + "/release/" + yearsdir[i] + "/acl-metadata.txt");
        List<Paper> list = loadPaperList(metadatafile, anndirname + "/papers_text/");
        for (Paper paper : list) {
            if (paper.getFile().exists()) {
                File destFile = new File(outputdirname + "/" + paper.getId() + "_" + paper.getYear());
                if (!destFile.exists()) {
                    FileUtils.copyFile(paper.getFile(), destFile);
                }/*  www .  j av  a2  s.  c om*/
            } else {
                Logger.getLogger(AAN2file.class.getName()).log(Level.WARNING, "Paper not found: {0}",
                        paper.getFile());
            }
        }
    }
}

From source file:de.uzk.hki.da.grid.IrodsGridFacadeTest.java

/**
 * Put file already exists with applicable checksum.
 *
 * @throws Exception the exception/*from  ww  w .j a  v  a  2s . co m*/
 */
@Test
public void putFileAlreadyExistsWithApplicableChecksum() throws Exception {
    FileUtils.copyFile(temp, new File(irodsDir + "/aip/123456/urn.tar"));
    when(isc.executeRule(anyString(), anyString())).thenReturn("1");

    when(isc.fileExists(anyString())).thenReturn(true);

    assertEquals(true, ig.put(temp, "123456/urn.tar", sp, null));
    assertEquals(true, new File(irodsDir + "/aip/123456/urn.tar").exists());
}

From source file:ml.shifu.shifu.core.pmml.PMMLVerifySuit.java

public boolean doVerification() throws Exception {
    // Step 1. Eval the scores using SHIFU
    File originModel = new File(this.modelConfigPath);
    File tmpModel = new File("ModelConfig.json");

    File originColumn = new File(this.columnConfigpath);
    File tmpColumn = new File("ColumnConfig.json");

    File modelsDir = new File(this.modelsPath);
    File tmpModelsDir = new File("models");

    FileUtils.copyFile(originModel, tmpModel);
    FileUtils.copyFile(originColumn, tmpColumn);
    FileUtils.copyDirectory(modelsDir, tmpModelsDir);

    // run evaluation set
    ShifuCLI.runEvalScore(this.evalSetName, null);
    File evalScore = new File("evals" + File.separator + this.evalSetName + File.separator + "EvalScore");

    Map<String, Object> params = new HashMap<String, Object>();
    params.put(ExportModelProcessor.IS_CONCISE, this.isConcisePmml);
    ShifuCLI.exportModel(null, params);/*from   w  w w  . j av a 2 s  .com*/

    // Step 2. Eval the scores using PMML and compare it with SHIFU output

    String DataPath = this.evalDataPath;
    String OutPath = "./pmml_out.dat";
    for (int index = 0; index < modelCnt; index++) {
        String num = Integer.toString(index);
        String pmmlPath = "pmmls" + File.separator + this.modelName + num + ".pmml";

        if (ModelTrainConf.ALGORITHM.NN.equals(algorithm)) {
            evalNNPmml(pmmlPath, DataPath, OutPath, this.delimiter, "model" + num);
        } else if (ModelTrainConf.ALGORITHM.LR.equals(algorithm)) {
            evalLRPmml(pmmlPath, DataPath, OutPath, this.delimiter, "model" + num);
        } else {
            logger.error("The algorithm - {} is not supported yet.", algorithm);
            return false;
        }

        boolean status = compareScore(evalScore, new File(OutPath), "model" + num, "\\|", this.scoreDiff);
        if (!status) {
            return status;
        }

        FileUtils.deleteQuietly(new File(OutPath));
    }

    FileUtils.deleteQuietly(tmpModel);
    FileUtils.deleteQuietly(tmpColumn);
    FileUtils.deleteDirectory(tmpModelsDir);

    FileUtils.deleteQuietly(new File("./pmmls"));
    FileUtils.deleteQuietly(new File("evals"));

    return true;
}

From source file:com.adaptris.core.lms.LargeFsProducer.java

private void copy(FileBackedMessage msg, File t) throws Exception {
    File fileToWriteTo = t;// w ww  .  j a  v  a 2 s. c  o m
    if (getTempDirectory() != null) {
        File tmpFile = createTempFile(msg);
        log.trace("Writing to temporary file {}", tmpFile.getCanonicalPath());
        fileToWriteTo = tmpFile;
    }
    try {
        FileUtils.copyFile(msg.currentSource(), fileToWriteTo);
    } catch (IOException e) {
        if (e.getMessage().contains("Failed to copy full contents")) {
            // FileUtils.copyFile uses FileChannel.transferFrom(), which has been
            // causing
            // some problems with NFS mounts, so let's just try again.
            // After all it's a "large file";
            fileToWriteTo.delete();
            FileUtils.copyFile(msg.currentSource(), fileToWriteTo);
        } else {
            throw e;
        }
    }
    if (getTempDirectory() != null) {
        log.trace("Renaming temporary file to " + t.getCanonicalPath());
        fileToWriteTo.renameTo(t);
    }
}