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

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

Introduction

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

Prototype

public static void copyFileToDirectory(File srcFile, File destDir) throws IOException 

Source Link

Document

Copies a file to a directory preserving the file date.

Usage

From source file:co.runrightfast.vertx.orientdb.impl.embedded.EmbeddedOrientDBServiceTest.java

@BeforeClass
public static void setUpClass() throws Exception {
    orientdbHome.mkdirs();//from   w  w w  .j a  va  2s.c o  m
    FileUtils.cleanDirectory(orientdbHome);
    FileUtils.deleteDirectory(orientdbHome);
    log.logp(INFO, CLASS_NAME, "setUpClass",
            String.format("orientdbHome.exists() = %s", orientdbHome.exists()));

    final File configDirSrc = new File("src/test/resources/orientdb/config");
    final File configDirTarget = new File(orientdbHome, "config");
    FileUtils.copyFileToDirectory(new File(configDirSrc, "default-distributed-db-config.json"),
            configDirTarget);
    FileUtils.copyFileToDirectory(new File(configDirSrc, "hazelcast.xml"), configDirTarget);

    final ApplicationId appId = ApplicationId.builder().group("co.runrightfast")
            .name("runrightfast-vertx-orientdb").version("1.0.0").build();
    final AppEventLogger appEventLogger = new AppEventJDKLogger(appId);

    final EmbeddedOrientDBServiceConfig config = EmbeddedOrientDBServiceConfig.builder()
            .orientDBRootDir(orientdbHome.toPath()).handler(new OGraphServerHandlerConfig())
            .handler(EmbeddedOrientDBServiceTest::oHazelcastPlugin)
            .handler(EmbeddedOrientDBServiceTest::oServerSideScriptInterpreter)
            .networkConfig(oServerNetworkConfiguration())
            .user(new OServerUserConfiguration(ROOT_USER, "root", "*"))
            .property(OGlobalConfiguration.DB_POOL_MIN, "1").property(OGlobalConfiguration.DB_POOL_MAX, "50")
            .databasePoolConfig(new OrientDBPoolConfig(CLASS_NAME, "remote:localhost/" + CLASS_NAME, "admin",
                    "admin", 10, ImmutableSet.of(() -> new SetCreatedOnAndUpdatedOn())))
            .lifecycleListener(() -> new RunRightFastOrientDBLifeCycleListener(appEventLogger)).build();

    service = new EmbeddedOrientDBService(config);
    ServiceUtils.start(service);
    initDatabase();
}

From source file:de.tudarmstadt.ukp.experiments.argumentation.clustering.debatefiltering.LuceneSearcher.java

private void searchAndCopy() throws Exception {
    String[] topics = { "homeschooling", "mainstreaming", "private public school", "single sex co-ed schools",
            "redshirting", "prayer schools" };
    for (String query : topics) {
        List<String> result = retrieveTopNDocs(query, 200);

        for (String filename : result) {
            File sourceFile = new File(this.debatesSourceDir, filename);

            File targetDir = new File(this.mainDebatesOutputDir, query);
            targetDir.mkdirs();//from  w w w  . ja  v  a  2 s.c  o  m

            FileUtils.copyFileToDirectory(sourceFile, targetDir);
            System.out.println("Copying " + sourceFile + " to " + targetDir);
        }
    }
}

From source file:com.huawei.streaming.cql.executor.mergeuserdefinds.Merger.java

private void copyFilesToTmp(Application app) throws IOException {
    String[] files = app.getUserFiles();

    if (files != null) {
        for (String file : files) {
            FileUtils.copyFileToDirectory(new File(file), tmpOutputDir);
        }//ww w  . ja  v  a2 s  .  c o m
    }

    if (Strings.isNullOrEmpty(System.getProperty("cql.dependency.jar"))) {
        //for unit test, not throw exception here.
        LOG.error("Failed to found cql.dependency.jar path in System properties.");
    } else {
        String path = System.getProperty("cql.dependency.jar");
        FileUtils.copyFileToDirectory(new File(URLDecoder.decode(path, "UTF-8")), tmpOutputDir);
    }
}

From source file:com.sangupta.pep.Generator.java

private void copyResource(Resource resource) throws IOException {
    if (resource == null) {
        return;//from  w ww  .  jav a2 s  .  c  o m
    }

    FileUtils.copyFileToDirectory(new File(resource.getUrl()), this.parentDir);
}

From source file:net.sf.infrared.tool.util.FileUtil.java

public void copyFileToDirectory(File file, File dir) {
    try {/*  w ww . j  a  va 2 s. com*/
        FileUtils.copyFileToDirectory(file, dir);
    } catch (IOException ex) {
        throw new InfraredToolException("Failed to copy file " + file + "to directory" + dir, ex);
    }

}

From source file:com.doculibre.constellio.services.BackupServicesImpl.java

@Override
public synchronized void restoreConfigBackup(String connectorName, String connectorTypeName) {
    File connectorInstanceDir = getConnectorInstanceDir(connectorName, connectorTypeName);
    List<File> backupFiles = listBackupFiles(connectorName, connectorTypeName);
    for (File backupFile : backupFiles) {
        try {// w  w  w  .j  a  v  a 2s. c o  m
            FileUtils.copyFileToDirectory(backupFile, connectorInstanceDir);
        } catch (IOException e) {
            throw new RuntimeException(e);
        }
    }
}

From source file:com.zyz.mobile.file.FileClipboard.java

/**
 * Copy the specified file/directory to the destination directory.
 *
 * @param srcFile the file/directory to be copied
 * @param destDir the destination directory
 * @throws IOException//from w w  w  . ja v  a 2  s. co m
 */
public static void copyFileToDirectory(File srcFile, File destDir) throws IOException {
    if (srcFile.isDirectory()) {
        FileUtils.copyDirectoryToDirectory(srcFile, destDir);
    } else {
        FileUtils.copyFileToDirectory(srcFile, destDir);
    }
}

From source file:io.Tools.java

/**
 * Create test PDB and Chemcomp folder. Also all PDB files in resources are copied there so all test can use this
 * folder/*from  w  w w . j  a  v a  2  s.c o m*/
 *
 * @return
 */
public static String createPermanentTestFolder() {

    String d = System.getProperty("user.home");
    String builtTestFolder = d + File.separator + "Documents" + File.separator + testFolderName
            + File.separator;
    final File baseDir = new File(builtTestFolder);

    String builttestPDBFolder = builtTestFolder + File.separator + "pdb";
    baseDir.mkdirs();
    final File pdbDir = new File(builttestPDBFolder);
    if (Files.exists(Paths.get(builttestPDBFolder))) {
        try {
            FileUtils.deleteDirectory(pdbDir);
        } catch (IOException e) {
        }
    }
    pdbDir.mkdir();

    String builttestChemcompFolder = builtTestFolder + File.separator + "chemcomp";
    final File chemcompDir = new File(builttestChemcompFolder);
    if (Files.exists(Paths.get(builttestChemcompFolder))) {
        try {
            FileUtils.deleteDirectory(chemcompDir);
        } catch (IOException e) {
        }
    }

    chemcompDir.mkdirs();

    pdbDir.mkdir();
    testChemcompFolder = builtTestFolder;
    testPDBFolder = builttestPDBFolder;

    String resourcesPDBFolder = null;
    try {
        URL url = BiojavaReaderFromPDBFolderTest.class.getClassLoader().getResource("pdb/1di9.cif.gz");
        File pdb1di9file = new File(url.toURI());
        resourcesPDBFolder = pdb1di9file.getParent();
        Map<String, List<MMcifFileInfos>> indexPDBFileInFolder = IOTools
                .indexPDBFileInFolder(new File(resourcesPDBFolder).toString());
        for (Map.Entry<String, List<MMcifFileInfos>> entry : indexPDBFileInFolder.entrySet()) {
            try {
                FileUtils.copyFileToDirectory(new File(entry.getValue().get(0).getPathToFile().toString()),
                        pdbDir);
            } catch (IOException e) {
                e.printStackTrace();
            }
        }

    } catch (URISyntaxException e) {
        e.printStackTrace();
    }

    String resourcesChemcompFolder = null;
    try {
        URL url = BiojavaReaderFromPDBFolderTest.class.getClassLoader().getResource("chemcomp/0DY.cif.gz");
        File chemcomp0DY = new File(url.toURI());
        resourcesChemcompFolder = chemcomp0DY.getParent();
        Map<String, List<Path>> indexPDBFileInFolder = IOTools
                .indexChemcompFileInFolder(new File(resourcesChemcompFolder).toString());
        for (Map.Entry<String, List<Path>> entry : indexPDBFileInFolder.entrySet()) {
            try {
                FileUtils.copyFileToDirectory(new File(entry.getValue().get(0).toString()),
                        new File(builttestChemcompFolder));
            } catch (IOException e) {
                e.printStackTrace();
            }
        }

    } catch (URISyntaxException e) {
        e.printStackTrace();
    }
    return testChemcompFolder;
}

From source file:ch.unibas.charmmtools.generate.inputs.CHARMM_Generator_DGHydr.java

private void copyAndFixPaths() {
    try {//from   ww  w.j  av  a2s. c  om
        FileUtils.copyFileToDirectory(new File(solu_cor), myDir);

        if (this.solv_cor != null) {
            FileUtils.copyFileToDirectory(new File(solv_cor), myDir);
        }

        FileUtils.copyFileToDirectory(new File(solu_top), myDir);

        if (this.solv_top != null) {
            FileUtils.copyFileToDirectory(new File(solv_top), myDir);
        }

        FileUtils.copyFileToDirectory(new File(par), myDir);

        FileUtils.copyFileToDirectory(new File(lpun), myDir);

    } catch (IOException | NullPointerException ex) {
        logger.error("An error append while copying files to subdirectory " + this.myDir.getAbsolutePath()
                + " : " + ex.getMessage());
    }

    this.solu_cor = new File(solu_cor).getName();
    if (this.solv_cor != null) {
        this.solv_cor = new File(solv_cor).getName();
    }
    this.solu_top = new File(solu_top).getName();
    if (this.solv_top != null) {
        this.solv_top = new File(solv_top).getName();
    }
    this.par = new File(par).getName();
    this.lpun = new File(lpun).getName();
}

From source file:com.athomas.androidkickstartr.util.LibraryHelper.java

private void copyToCompileLibs(String jar) {
    try {//from   w  w  w .  j a  v a 2 s .com
        File library = fileHelper.getLibraryFile(jar);
        File extCompileDir = fileHelper.getTargetExtCompileDir();
        FileUtils.copyFileToDirectory(library, extCompileDir);
    } catch (IOException e) {
        LOGGER.error("a problem occured during the copy of " + jar + " to compile-libs", e);
    }
}