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

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

Introduction

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

Prototype

public static void copyDirectory(File srcDir, File destDir) throws IOException 

Source Link

Document

Copies a whole directory to a new location preserving the file dates.

Usage

From source file:de.uzk.hki.da.model.WorkAreaTests.java

@Before
public void setUp() throws IOException {
    FileUtils.copyDirectory(WORK_AREA_ROOT_PATH_TMP.toFile(), WORK_AREA_ROOT_PATH.toFile());

    o.setIdentifier(TC.IDENTIFIER);//from  w  ww  . ja  v  a2  s  .  c om
    n.setWorkAreaRootPath(WORK_AREA_ROOT_PATH);
    User c = new User();
    c.setShort_name(TEST_USER_SHORT_NAME);
    o.setContractor(c);
    Package pkg = new Package();
    pkg.setDelta(1);
    pkg.setContainerName(CONTAINER_NAME);
    pkg.setId(1);
    o.getPackages().add(pkg);
    wa = new WorkArea(n, o);
}

From source file:azkaban.jobtype.JobTypeManagerTest.java

@Before
public void setUp() throws Exception {
    File jobTypeDir = temp.newFolder(TEST_PLUGIN_DIR);
    testPluginDirPath = jobTypeDir.getCanonicalPath();

    URL resourceUrl = Resources.getResource("plugins/jobtypes");
    assertNotNull(resourceUrl);/*w ww  .jav  a  2 s  . co m*/
    FileUtils.copyDirectory(new File(resourceUrl.toURI()), jobTypeDir);
    manager = new JobTypeManager(testPluginDirPath, null, this.getClass().getClassLoader());
}

From source file:au.org.ala.delta.confor.ToIntTest.java

@Test
public void testSampleToInt() throws Exception {

    File tointDirectory = urlToFile("/dataset/");
    File dest = new File(System.getProperty("java.io.tmpdir"));
    FileUtils.copyDirectory(tointDirectory, dest);

    String tointFilePath = FilenameUtils.concat(dest.getAbsolutePath(), "sample/toint");

    CONFOR.main(new String[] { tointFilePath });

    File ichars = new File(FilenameUtils.concat(dest.getAbsolutePath(), "sample/ichars"));
    File iitems = new File(FilenameUtils.concat(dest.getAbsolutePath(), "sample/iitems"));

    IntkeyDataset dataSet = IntkeyDatasetFileReader.readDataSet(ichars, iitems);

    File expectedIChars = new File(
            FilenameUtils.concat(dest.getAbsolutePath(), "sample/expected_results/ichars"));
    File expectedIItems = new File(
            FilenameUtils.concat(dest.getAbsolutePath(), "sample/expected_results/iitems"));

    IntkeyDataset expectedDataSet = IntkeyDatasetFileReader.readDataSet(expectedIChars, expectedIItems);

    compare(dataSet, expectedDataSet);/* w w w. j  a va  2  s . c om*/

}

From source file:com.github.pemapmodder.pocketminegui.utils.Utils.java

private static File installLinuxPHP(File home, InstallProgressReporter progress) {
    progress.report(0.0);/* ww w.  j a va  2s.  c o  m*/
    File bin = new File(home, ".pmgui_tmp_pm_linux_installer");
    bin.mkdirs();
    try {
        InputStream get = new URL("http", "get.pocketmine.net", "").openStream();
        Process bash = new ProcessBuilder("bash -s - -v development").directory(bin)
                .redirectOutput(ProcessBuilder.Redirect.INHERIT).redirectError(ProcessBuilder.Redirect.INHERIT)
                .start();
        progress.report(0.25);
        byte[] bytes = IOUtils.toByteArray(get);
        progress.report(0.5);
        bash.getOutputStream().write(bytes);
        int result = bash.waitFor();
        progress.report(0.75);
        if (result == 0) {
            File out = new File(bin, "bin");
            FileUtils.copyDirectory(out, new File(home, "bin"));
            FileUtils.deleteDirectory(bin);
            File output = new File(out, "php7/bin/php");
            progress.completed(output);
            return output;
        } else {
            FileUtils.deleteDirectory(bin);
            return null;
        }
    } catch (IOException | InterruptedException e) {
        e.printStackTrace();
        try {
            FileUtils.deleteDirectory(bin);
        } catch (IOException e1) {
        }
        return null;
    }
}

From source file:com.digitalgeneralists.assurance.model.merge.BidirectionalMergeEngine.java

@Override
public void mergeResult(ComparisonResult result, IProgressMonitor monitor) {
    File sourceFile = result.getSource().getFile();
    File targetFile = result.getTarget().getFile();

    if (monitor != null) {
        StringBuilder message = new StringBuilder(512);
        monitor.publish(message.append("Merging ").append(targetFile.toString()).append(" to ")
                .append(sourceFile.toString()).toString());
        message.setLength(0);/*from   w  w w .j a  va 2 s  .  com*/
        message = null;
    }

    if (sourceFile.exists()) {
        try {
            if (sourceFile.isDirectory()) {
                FileUtils.copyDirectory(sourceFile, targetFile);
            } else {
                FileUtils.copyFile(sourceFile, targetFile);
            }
            result.setResolution(AssuranceResultResolution.REPLACE_TARGET);
        } catch (IOException e) {
            logger.error("An error occurred when replacing the target with the source.");
            result.setResolution(AssuranceResultResolution.PROCESSING_ERROR_ENCOUNTERED);
            result.setResolutionError(e.getMessage());
        }
    } else {
        if (targetFile.exists()) {
            try {
                if (targetFile.isDirectory()) {
                    FileUtils.copyDirectory(targetFile, sourceFile);
                } else {
                    FileUtils.copyFile(targetFile, sourceFile);
                }
                result.setResolution(AssuranceResultResolution.REPLACE_SOURCE);
            } catch (IOException e) {
                logger.error("An error occurred when replacing the source with the target.");
                result.setResolution(AssuranceResultResolution.PROCESSING_ERROR_ENCOUNTERED);
                result.setResolutionError(e.getMessage());
            }
        }
    }

    sourceFile = null;
    targetFile = null;
}

From source file:com.kylinolap.job.hadoop.cube.MergeCuboidJobTest.java

@Test
public void test() throws Exception {
    // String input =
    // "src/test/resources/data/base_cuboid,src/test/resources/data/6d_cuboid";
    String output = "target/test-output/merged_cuboid";
    String cubeName = "test_kylin_cube_with_slr_ready";
    String jobname = "merge_cuboid";

    File baseFolder = File.createTempFile("kylin-f24668f6-dcff-4cb6-a89b-77f1119df8fa-", "base");
    baseFolder.delete();/*from  w ww .j  a  v a2s.c  om*/
    baseFolder.mkdir();
    FileUtils.copyDirectory(new File("src/test/resources/data/base_cuboid"), baseFolder);
    baseFolder.deleteOnExit();

    File sixDFolder = File.createTempFile("kylin-f24668f6-dcff-4cb6-a89b-77f1119df8fa-", "6d");
    sixDFolder.delete();
    sixDFolder.mkdir();
    FileUtils.copyDirectory(new File("src/test/resources/data/base_cuboid"), sixDFolder);
    sixDFolder.deleteOnExit();

    FileUtil.fullyDelete(new File(output));

    // CubeManager cubeManager =
    // CubeManager.getInstanceFromEnv(this.getTestConfig());

    String[] args = { "-input", baseFolder.getAbsolutePath() + "," + sixDFolder.getAbsolutePath(), "-cubename",
            cubeName, "-segmentname", "20130331080000_20131212080000", "-output", output, "-jobname", jobname };
    assertEquals("Job failed", 0, ToolRunner.run(conf, new MergeCuboidJob(), args));

}

From source file:com.google.cloud.tools.gradle.endpoints.framework.ProjectTests.java

@Test
public void testServer() throws IOException, URISyntaxException {

    FileUtils.copyDirectory(new File(getClass().getClassLoader().getResource("projects/server").toURI()),
            testProjectDir.getRoot());/*from www  .j  a  va2  s  . c o  m*/

    BuildResult buildResult = GradleRunner.create().withProjectDir(testProjectDir.getRoot())
            .withPluginClasspath()
            .withArguments("endpointsClientLibs", "endpointsDiscoveryDocs", "endpointsOpenApiDocs").build();

    // client lib geneneration actually generates a discovery doc as well, so check the
    // above directory for that
    File clientLibRoot = new File(testProjectDir.getRoot(), "/build/endpointsClientLibs");
    Assert.assertTrue(new File(clientLibRoot, "testApi-v1-java.zip").exists());
    Assert.assertEquals(1, clientLibRoot.listFiles().length);

    File discoveryDocRoot = new File(testProjectDir.getRoot(), "/build/endpointsDiscoveryDocs");
    Assert.assertTrue(new File(discoveryDocRoot, "testApi-v1-rest.discovery").exists());
    Assert.assertEquals(1, discoveryDocRoot.listFiles().length);

    File openApiDocRoot = new File(testProjectDir.getRoot(), "/build/endpointsOpenApiDocs");
    Assert.assertTrue(new File(openApiDocRoot, "openapi.json").exists());
    Assert.assertEquals(1, openApiDocRoot.listFiles().length);
}

From source file:com.photon.phresco.framework.actions.LoginTest.java

public void copyFileAndFolder() {
    try {/*from w  w w  .jav a2 s  . c  o m*/
        File srcDir = new File("/Users/kaleeswaran/workspace/projects/PHR_Walgreens_latest/make/2012-09-17-1");
        File destDir = new File(
                "/Users/kaleeswaran/workspace/projects/PHR_Walgreens_latest/do_not_checkin/static-analysis-report");
        FileUtils.copyDirectory(srcDir, destDir);
    } catch (Exception e) {
        e.printStackTrace();
    }
}

From source file:de.felixschulze.teamcity.xcode.tools.ClangBuildOutputParser.java

protected void handleLine(String line) {
    Matcher m;//w  w w  .  j av a 2  s  . c o m
    m = BUG_COUNTER.matcher(line);
    if (m.matches()) {
        buildListener.message(
                "##teamcity[buildStatus status='FAILURE' text='Analyzer found: " + m.group(1) + " bugs']");
        return;
    }

    m = HTML_FILE.matcher(line);
    if (m.matches()) {
        File artefactDir = new File(workingDirectory.getAbsolutePath() + "/analyzer");
        File reportDir = new File(m.group(1));
        try {
            FileUtils.copyDirectory(reportDir, artefactDir);
        } catch (IOException e) {
            buildListener.message("Problem while copying clang report: " + e.getMessage());
        }
        return;
    }

}

From source file:it.duplication.CrossModuleDuplicationsTest.java

@Before
public void setUpProject() throws IOException {
    orchestrator.resetData();//from  www.jav a2 s . com
    ItUtils.restoreProfile(orchestrator, getClass().getResource("/duplication/xoo-duplication-profile.xml"));

    FileUtils.copyDirectory(ItUtils.projectDir(PROJECT_DIR), temp.getRoot());
    projectDir = temp.getRoot();
}