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.sap.prd.mobile.ios.mios.FatBinaryTest.java

@Before
public void prepareCopyOfRemoteRepo() throws Exception {
    remoteRepoDir = new File(masterRemoteRepoDir.getParentFile(),
            "FatBinaryTest-" + System.currentTimeMillis());
    FileUtils.copyDirectory(masterRemoteRepoDir, remoteRepoDir);
}

From source file:com.santiagolizardo.madcommander.dialogs.progressive.CopyProgressDialog.java

@Override
public void run() {
    if (srcPath.equals(dstPath)) {
        DialogFactory.showErrorMessage(sourceListing.getParent(), "You cannot copy a file to itself!");
        dispose();/*from  w  ww  .ja  v  a2  s .co  m*/
        return;
    }

    List<File> selectedFiles = sourceListing.getSelectedFiles();
    int numFiles = selectedFiles.size();
    myProcess.totalProgress = 0;
    for (int i = 0; i < selectedFiles.size(); i++) {
        myProcess.currentFile = selectedFiles.get(i).getName();
        myProcess.currentProgress = 0;
        currentFileLabel.setText("Current file: " + myProcess.currentFile);
        String fullSrc = srcPath + File.separator + myProcess.currentFile;
        String fullDst = dstPath + File.separator + myProcess.currentFile;

        StringBuilder buffer = new StringBuilder();
        buffer.append("Copying [ ");
        buffer.append(fullSrc);
        buffer.append(" => ");
        buffer.append(fullDst);
        buffer.append(" ]");
        logger.info(buffer.toString());
        try {
            File fileSrc = new File(fullSrc);
            File fileDst = new File(fullDst);

            if (fileSrc.isDirectory())
                FileUtils.copyDirectory(fileSrc, fileDst);
            else
                FileUtils.copyFile(fileSrc, fileDst);

            myProcess.currentProgress = 100;
            myProcess.totalProgress = (i * 100) / numFiles;

            if (myProcess.cancel) {
                logger.info("Cancel copying.");
                return;
            }
        } catch (IOException e) {
            e.printStackTrace();
        }
    }

    myProcess.totalProgress = 100;
}

From source file:mesclasses.view.ConfigStockageController.java

@FXML
void changeRoot() {
    File source = new File(conf.getRootDir()).getParentFile();
    DirectoryChooser chooser = new DirectoryChooser();
    chooser.setTitle("Choix du rpertoire de sauvegarde");
    chooser.setInitialDirectory(source);

    File dir = chooser.showDialog(primaryStage);
    if (dir != null && !dir.getAbsolutePath().equals(source.getAbsolutePath())) {
        LOG.info("Nouveau chemin de stockage saisi : " + dir);
        try {//from   w  ww  .  ja  v  a2s.  c  o  m
            LOG.info("Copie des fichiers vers " + dir);
            FileUtils.copyDirectory(source, dir);
        } catch (IOException e) {
            notif("Impossible de dplacer les fichiers du rpertoire " + conf.getRootDir() + " : "
                    + e.getMessage());
            return;
        }
        FileConfigurationManager.setCustomStoragePath(dir.getAbsolutePath());
        try {
            LOG.info("Suppression de " + source);
            FileUtils.deleteDirectory(source);
        } catch (IOException e) {
            notif("Impossible de supprimer les fichiers du rpertoire " + source + " : " + e.getMessage());
        }
        init();
    }
}

From source file:ml.shifu.shifu.actor.EvalModelActorTest.java

public void testActor() throws IOException, InterruptedException {
    Environment.setProperty(Environment.SHIFU_HOME, ".");

    File tmpModels = new File("models");
    File tmpCommon = new File("common");

    File models = new File("src/test/resources/example/cancer-judgement/ModelStore/ModelSet1/models");
    FileUtils.copyDirectory(models, tmpModels);

    File tmpEvalA = new File("evals");
    FileUtils.forceMkdir(tmpEvalA);/*from  w  w  w  .  j  a v  a2s  .c  om*/

    ActorRef modelEvalRef = actorSystem.actorOf(new Props(new UntypedActorFactory() {
        private static final long serialVersionUID = -1437127862571741369L;

        public UntypedActor create() {
            return new EvalModelActor(modelConfig, columnConfigList, new AkkaExecStatus(true), evalConfig);
        }
    }), "model-evaluator");

    List<Scanner> scanners = ShifuFileUtils.getDataScanners(
            "src/test/resources/example/cancer-judgement/DataStore/EvalSet1", SourceType.LOCAL);
    modelEvalRef.tell(new AkkaActorInputMessage(scanners), modelEvalRef);

    while (!modelEvalRef.isTerminated()) {
        Thread.sleep(5000);
    }

    File outputFile = new File("evals/EvalA/EvalScore");
    Assert.assertTrue(outputFile.exists());

    FileUtils.deleteDirectory(tmpModels);
    FileUtils.deleteDirectory(tmpCommon);
    FileUtils.deleteDirectory(tmpEvalA);
}

From source file:io.treefarm.plugins.haxe.components.nativeProgram.OpenFLNativeProgram.java

public void initialize(Artifact artifact, File outputDirectory, File pluginHome, Set<String> path,
        File nmeDirectory, File openflNativeDirectory) {
    if (nmeDirectory != null && nmeDirectory.exists()) {
        this.nmeDirectory = nmeDirectory;
    }/*  w ww  .j a v a2 s . c  o  m*/
    initialize(artifact, outputDirectory, pluginHome, path);

    if (this.nmeDirectory != null && openflNativeDirectory != null && openflNativeDirectory.exists()) {
        File nmeNDLLDirectory = new File(nmeDirectory, "ndll");
        File openflNDLLDirectory = new File(openflNativeDirectory, "ndll");

        /*for (String fileName : nmeNDLLDirectory.list())
        {
        File ndllDirectory = new File(nmeNDLLDirectory, fileName);
        if (ndllDirectory.isDirectory()) {
            FileUtils.copyDirectory(ndllDirectory);
        }
        }*/
        try {
            FileUtils.copyDirectory(nmeNDLLDirectory, openflNDLLDirectory);
        } catch (IOException e) {
            logger.error("Unable to copy NDLL files from NME to OpenFL Native");
        }
    }
}

From source file:com.twinsoft.convertigo.beans.core.MobilePlatform.java

private void checkFolder() {
    File folder = getResourceFolder();
    if (!folder.exists()) {
        try {// w  ww.ja  v a2  s.  com
            File templateFolder = new File(Engine.TEMPLATES_PATH,
                    "base/DisplayObjects/platforms/" + getClass().getSimpleName());
            FileUtils.copyDirectory(templateFolder, folder);
        } catch (IOException e) {
            Engine.logBeans.warn("(MobilePlatform) The folder '" + folder.getAbsolutePath()
                    + "' doesn't exist and cannot be created", e);
        }
    }
}

From source file:azkaban.soloserver.AzkabanSingleServer.java

/**
 * To enable "run out of the box for testing".
 *//* ww  w.  j av  a2s.c o m*/
private static String[] prepareDefaultConf() throws IOException {
    final File templateFolder = new File("test/local-conf-templates");
    final File localConfFolder = new File("local/conf");
    if (!localConfFolder.exists()) {
        FileUtils.copyDirectory(templateFolder, localConfFolder.getParentFile());
        log.info("Copied local conf templates from " + templateFolder.getAbsolutePath());
    }
    log.info("Using conf at " + localConfFolder.getAbsolutePath());
    return new String[] { "-conf", "local/conf" };
}

From source file:com.huangyunkun.jviff.core.impl.HtmlResultReport.java

private void copyResources(File outputDir) throws IOException {
    String frontFolder = Resources.getResource("static").getFile();
    FileUtils.copyDirectory(new File(frontFolder), new File(outputDir, "static"));
}

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

@Before
public void setUp() throws IOException {
    grid = mock(FakeGridFacade.class);
    action.setGridFacade(grid);/*from  w  ww.  jav  a2 s  .c  o m*/
    action.setJmsMessageServiceHandler(mock(JmsMessageServiceHandler.class));
    n.setWorkAreaRootPath(WORK_AREA_ROOT_PATH);
    ig = mock(IngestGate.class);
    action.setIngestGate(ig);
    when(ig.canHandle((Long) anyObject())).thenReturn(true);
    FileUtils.copyDirectory(Path.makeFile(WORK_AREA_ROOT_PATH, WorkArea.WORK + UNDERSCORE),
            Path.makeFile(WORK_AREA_ROOT_PATH, WorkArea.WORK));
}

From source file:de.codecentric.janus.plugin.library.SeleniumAdapter.java

private void deleteConfigurationFiles() throws Exception {
    String cwd = System.getProperty("user.dir");
    String jenkinsWorkspace = cwd.replace("janus-plugin-integration-test",
            "janus-plugin" + File.separator + "work");
    String workspaceTemplate = cwd + File.separator + "src" + File.separator + "test" + File.separator
            + "resources" + File.separator + "jenkins-workspace-template";

    // delete all configuration data
    FileUtils.deleteDirectory(new File(jenkinsWorkspace));

    // copy config template
    FileUtils.copyDirectory(new File(workspaceTemplate), new File(jenkinsWorkspace));
}