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:com.yifanlu.PSXperiaTool.PSXperiaTool.java

private File createTempDir(File dataDir) throws IOException {
    nextStep("Creating temporary directory.");
    File tempDir = new File(new File("."), "/.psxperia." + (int) (Math.random() * 1000));
    if (tempDir.exists())
        FileUtils.deleteDirectory(tempDir);
    if (!tempDir.mkdirs())
        throw new IOException("Cannot create temporary directory!");
    FileUtils.copyDirectory(dataDir, tempDir);
    Logger.debug("Created temporary directory at, %s", tempDir.getPath());
    return tempDir;
}

From source file:com.gs.obevo.util.FileUtilsCobra.java

public static void copyDirectory(File srcDir, File destDir) {
    try {//from w  w  w  . ja  v a 2  s  .  c  o m
        FileUtils.copyDirectory(srcDir, destDir);
    } catch (IOException e) {
        throw new RuntimeException(e);
    }
}

From source file:info.magnolia.filesystembrowser.app.action.DuplicateFileAction.java

@Override
public void execute() throws ActionExecutionException {
    Object itemId = contentConnector.getItemId(item);
    if (itemId instanceof File) {
        File file = (File) itemId;
        File copy = createFileCopy(file);
        try {//ww w . j  ava2 s  . c  o m
            if (file.isFile()) {
                FileUtils.copyFile(file, copy);
            } else {
                FileUtils.copyDirectory(file, copy);
            }

            eventBus.fireEvent(new ContentChangedEvent(file));
        } catch (IOException e) {
            String message = translator.translate("ui-framework.abstractcommand.executionfailure");
            uiContext.openNotification(MessageStyleTypeEnum.ERROR, true, message);
        }
    }
}

From source file:io.siddhi.extension.io.file.FileSourceLineModeTestCase.java

@BeforeMethod
public void doBeforeMethod() {
    count.set(0);/*  w w  w.  j  a va 2 s.  c  o  m*/
    try {
        FileUtils.copyDirectory(sourceRoot, newRoot);
        movedFiles = new File(moveAfterProcessDir);
    } catch (IOException e) {
        throw new TestException("Failed to copy files from " + sourceRoot.getAbsolutePath() + " to "
                + newRoot.getAbsolutePath() + " which are required for tests. Hence aborting tests.", e);
    }
}

From source file:eu.delving.sip.Mockery.java

public void prepareDataset(String prefix, String recordRootPath, String uniqueElementPath)
        throws StorageException, IOException, MetadataException {
    this.prefix = prefix;
    storage.createDataSet(prefix, ORG);/*from  w  w w. j a  v a2  s.co  m*/
    dataSetDir = new File(root, String.format("%s_%s", prefix, ORG));
    hints.clear();
    hints.put(Storage.RECORD_ROOT_PATH, recordRootPath);
    hints.put(Storage.UNIQUE_ELEMENT_PATH, uniqueElementPath);
    File factsSourceDir = new File(getClass().getResource(String.format("/test/%s/dataset", prefix)).getFile());
    if (!factsSourceDir.isDirectory())
        throw new RuntimeException();
    FileUtils.copyDirectory(factsSourceDir, dataSetDir);
    dataSetModel.setDataSet(storage.getDataSets().get(dataSetDir.getName()), prefix);
    recMapping = dataSetModel.getMappingModel().getRecMapping();
    //        FileUtils.writeStringToFile(new File("/tmp/EAD-paths.txt"), recMapping.getRecDefTree().getPathsList());
}

From source file:com.fizzed.stork.maven.AssemblyMojo.java

@Override
public void execute() throws MojoExecutionException, MojoFailureException {
    if (!stageDirectory.exists()) {
        getLog().info("Creating stage directory: " + stageDirectory);
        stageDirectory.mkdirs();/*from   ww  w  .  j a v  a  2 s  . c  om*/
    }

    try {
        List<Artifact> artifacts = artifactsToStage();

        //
        // copy runtime dependencies to stage directory...
        //
        File stageLibDir = new File(stageDirectory, "lib");

        // directly pulled from maven Project.java (how it returns the getRuntimeClasspathElements() value)
        for (Artifact a : artifacts) {
            File f = a.getFile();
            if (f == null) {
                getLog().error("Project artifact was null (maybe not compiled into jar yet?)");
            } else {
                // generate final jar name (which appends groupId)
                String artifactName = a.getGroupId() + "." + a.getArtifactId() + "-" + a.getVersion() + ".jar";
                File stageArtificateFile = new File(stageLibDir, artifactName);
                FileUtils.copyFile(f, stageArtificateFile);
            }
        }

        // copy conf, bin, and share dirs
        File binDir = new File(project.getBasedir(), "bin");
        if (binDir.exists()) {
            File stageBinDir = new File(stageDirectory, "bin");
            FileUtils.copyDirectory(binDir, stageBinDir);
        }

        File confDir = new File(project.getBasedir(), "conf");
        if (confDir.exists()) {
            File stageConfDir = new File(stageDirectory, "conf");
            FileUtils.copyDirectory(confDir, stageConfDir);
        }

        File shareDir = new File(project.getBasedir(), "share");
        if (shareDir.exists()) {
            File stageShareDir = new File(stageDirectory, "share");
            FileUtils.copyDirectory(shareDir, stageShareDir);
        }

        // copy standard project resources (e.g. readme*, license*, changelog*, release* files)
        AssemblyUtils.copyStandardProjectResources(project.getBasedir(), stageDirectory);

        // tarball it up
        File tgzFile = AssemblyUtils.createTGZ(outputDirectory, stageDirectory, finalName);
        getLog().info("Generated maven stork assembly: " + tgzFile);

    } catch (Exception e) {
        throw new MojoExecutionException(e.getMessage(), e);
    }
}

From source file:hudson.plugins.jobConfigHistory.ConfigInfoCollectorTest.java

/**
 * Test of collect method, of class ConfigInfoCollector.
 *//* w w w  .j a  va 2  s  . co  m*/
@Test
public void testCollectJobFolder() throws Exception {
    String folderName = "FolderName";
    // Create folders
    FileUtils.copyDirectory(unpackResourceZip.getResource("config-history/jobs/Test1"),
            unpackResourceZip.getResource("config-history/jobs/" + folderName + "/jobs/Test1"));
    FileUtils.copyDirectory(unpackResourceZip.getResource("config-history/jobs/Test1"),
            unpackResourceZip.getResource("config-history/jobs/" + folderName + "/jobs/Test2"));
    assertThatFolderXHasYItemsOfTypeZ(folderName, 10, "other");
    assertThatFolderXHasYItemsOfTypeZ(folderName, 2, "created");
}

From source file:hudson.plugins.testlink.result.ResultSeekerTestCase.java

protected void setUp() throws Exception {
    super.setUp();

    project = createFreeStyleProject();//from  www.  j av  a 2 s .c o  m
    File temp = File.createTempFile("resultseeker", Long.toString(System.nanoTime()));

    if (!(temp.delete())) {
        throw new IOException("Could not delete temp directory " + temp);
    }

    if (!(temp.mkdir())) {
        throw new IOException("Could not create temp directory " + temp);
    }

    File workspaceFile = new File(temp, getResultsDirectory());

    if (!(workspaceFile.mkdirs())) {
        throw new IOException("Could not create temp workspace " + temp);
    }

    ClassLoader cl = ResultSeekerTestCase.class.getClassLoader();
    URL url = cl.getResource(getResultsDirectory());
    File junitDir = new File(url.getFile());

    FileUtils.copyDirectory(junitDir, workspaceFile);

    project.setCustomWorkspace(workspaceFile.getAbsolutePath());

    project.getBuildersList()
            .add(new ResultSeekerBuilder(getResultSeeker(), getAutomatedTestCases(), testlink));
}

From source file:it.sonarlint.cli.tools.SonarlintCli.java

public Path deployProject(String location) throws IOException {
    Path originalLoc = Paths.get("projects").resolve(location);
    String projectName = originalLoc.getFileName().toString();

    if (!Files.isDirectory(originalLoc)) {
        throw new IllegalArgumentException(
                "Couldn't find project directory: " + originalLoc.toAbsolutePath().toString());
    }//from  ww w  .j av a 2  s .c om

    cleanProject();
    project = Files.createTempDirectory(projectName);
    FileUtils.copyDirectory(originalLoc.toFile(), project.toFile());
    return project;
}

From source file:de.uzk.hki.da.cb.BuildAIPActionTests.java

/**
 * Sets the up.//w w  w. j av a  2 s.co  m
 *
 * @throws IOException Signals that an I/O exception has occurred.
 */
@Before
public void setUp() throws IOException {
    FileUtils.copyDirectory(backupPackagePath.toFile(), packageForkPath.toFile());
}