List of usage examples for org.apache.commons.io FileUtils copyDirectory
public static void copyDirectory(File srcDir, File destDir) throws IOException
From source file:bioLockJ.module.agent.RScriptAgent.java
protected void prepDownload() throws Exception { final String downloadDir = getDownloadDir(); if (downloadDir == null) { return;/* w w w . j a v a 2 s .c om*/ } final File newScript = new File(getOutputDir().getAbsolutePath() + File.separator + rScript.getName()); final BufferedReader reader = new BufferedReader(new FileReader(rScript)); final BufferedWriter writer = new BufferedWriter(new FileWriter(newScript)); for (String line = reader.readLine(); line != null; line = reader.readLine()) { if (line.startsWith(RScript.OUTPUT_DIR + " =")) { line = RScript.OUTPUT_DIR + " = \"" + downloadDir + LOCAL + File.separator + "\""; } if (line.startsWith(SCRIPT_DIR + " =")) { line = SCRIPT_DIR + " = \"" + downloadDir + "\""; } if (line.startsWith(RScript.INPUT_DIR + " =")) { line = RScript.INPUT_DIR + " = \"" + downloadDir + TABLES + File.separator + "\""; } writer.write(line + Constants.RETURN); } reader.close(); writer.close(); final String localPath = getOutputDir().getAbsolutePath() + File.separator + LOCAL; File f = new File(localPath + File.separator + RScript.getDataDirName()); f.mkdirs(); f = new File(localPath + File.separator + RScript.getGraphicsDirName()); f.mkdirs(); f = new File(localPath + File.separator + RScript.getLogDataDirName()); f.mkdirs(); f = new File(localPath + File.separator + RScript.getLogGraphicsDirName()); f.mkdirs(); f = new File(localPath + File.separator + RScript.R_LOG_DIR); f.mkdirs(); final File tableDir = new File(getOutputDir().getAbsolutePath() + File.separator + TABLES); tableDir.mkdirs(); FileUtils.copyDirectory(getInputDir(), tableDir); }
From source file:com.us.util.FileHelper.java
/** * ?//*from ww w . j av a 2 s .c o m*/ * * @param source / * @param target / */ public static void copy(File source, File target) { try { if (source.isDirectory() && target.isDirectory()) { FileUtils.copyDirectory(source, target); } else if (source.isFile() && target.isDirectory()) { FileUtils.copyFileToDirectory(source, target); } else if (source.isFile()) { FileUtils.copyFile(source, target); } } catch (IOException e) { log.error("?", e); } }
From source file:com.spotify.helios.ZooKeeperStandaloneServerManager.java
public void restore(final Path source) { try {//from w ww .j a v a 2s. c om FileUtils.deleteDirectory(dataDir); FileUtils.copyDirectory(source.toFile(), dataDir); } catch (IOException e) { throw Throwables.propagate(e); } }
From source file:net.java.javabuild.ExecuteMojo.java
private void afterPreparePackage() throws IOException { File webappResources = new File(BuilderFolders.WEBAPP_RESOURCES); if (webappResources.exists()) FileUtils.copyDirectory(webappResources, webappDirectory); }
From source file:com.athomas.androidkickstartr.Kickstartr.java
private void createDirectory() { LOGGER.info("generation of " + appDetails + " : " + appDetails); if (appDetails.isRestTemplate() || appDetails.isAcra()) { List<String> permissions = appDetails.getPermissions(); permissions.add("android.permission.INTERNET"); }/* w w w .j a v a 2s . c o m*/ try { copyResDir(); LOGGER.debug("res dir copied."); } catch (IOException e) { LOGGER.error("problem occurs during the resources copying", e); } try { generateSourceCode(); LOGGER.debug("source code generated from templates."); } catch (IOException e) { LOGGER.error("generated code file not generated", e); } try { File androidResDir = fileHelper.getTargetAndroidResDir(); File sourceResDir = fileHelper.getResDir(); FileUtils.copyDirectory(sourceResDir, androidResDir); LOGGER.debug("res dir copied."); } catch (IOException e) { LOGGER.error("problem occurs during the resources copying", e); } if (appDetails.isMaven()) { // create src/text/java - it avoids an error when import to Eclipse File targetTestDir = fileHelper.getTargetTestDir(); File removeMe = new File(targetTestDir, "REMOVE.ME"); try { removeMe.createNewFile(); } catch (IOException e) { LOGGER.error("an error occured during the REMOVE.ME file creation", e); } } try { TemplatesFileHelper templatesFileHelper = new TemplatesFileHelper(appDetails, fileHelper); templatesFileHelper.generate(); LOGGER.debug("files generated from templates."); } catch (IOException e) { LOGGER.error("problem during ftl files loading", e); } catch (TemplateException e) { LOGGER.error("problem during template processing", e); } try { if (appDetails.isEclipse()) { if (appDetails.isAndroidAnnotations()) { File targetEclipseJdtAptCorePrefsFile = fileHelper.getTargetEclipseJdtAptCorePrefsFile(); File eclipseJdtAptCorePrefs = fileHelper.getEclipseJdtAptCorePrefs(); FileUtils.copyFile(eclipseJdtAptCorePrefs, targetEclipseJdtAptCorePrefsFile); LOGGER.debug("org.eclipse.jdt.apt.core.prefs copied"); } File targetEclipseJdtCorePrefsFile = fileHelper.getTargetEclipseJdtCorePrefsFile(); File eclipseJdtCorePrefs = fileHelper.getEclipseJdtCorePrefs(); FileUtils.copyFile(eclipseJdtCorePrefs, targetEclipseJdtCorePrefsFile); LOGGER.debug("org.eclipse.jdt.core.prefs copied"); } } catch (IOException e) { LOGGER.error("a problem occured during the org.eclipse.jdt.apt.core.prefs copying", e); } LibraryHelper libraryManager = new LibraryHelper(appDetails, fileHelper); libraryManager.go(); LOGGER.debug("libraries copied"); }
From source file:io.bitsquare.gui.main.account.content.backup.BackupView.java
@Override protected void activate() { selectBackupDir.setOnAction(e -> { DirectoryChooser directoryChooser = new DirectoryChooser(); directoryChooser.setInitialDirectory(new File(preferences.getDefaultPath())); directoryChooser.setTitle("Select backup location"); File dir = directoryChooser.showDialog(stage); if (dir != null) { String backupDirectory = dir.getAbsolutePath(); preferences.setDefaultPath(backupDirectory); backUpLocationTextField.setText(backupDirectory); preferences.setBackupDirectory(backupDirectory); backupNow.setDisable(false); backupNow.setDefaultButton(true); selectBackupDir.setDefaultButton(false); }//w w w. ja va 2 s. c o m }); openDataDir.setOnAction(e -> { try { Utilities.openDirectory(dataDir); } catch (IOException e1) { log.error(e1.getMessage()); new Popup().warning("Cannot open directory.\nError =" + e1.getMessage()).show(); } }); backupNow.setOnAction(e -> { String backupDirectory = preferences.getBackupDirectory(); if (backupDirectory.length() > 0) { try { String dateString = new SimpleDateFormat("YYYY-MM-dd-HHmmss").format(new Date()); String destination = Paths.get(backupDirectory, "bitsquare_backup_" + dateString).toString(); FileUtils.copyDirectory(dataDir, new File(destination)); new Popup().feedback("Backup successfully saved at:\n" + destination).show(); } catch (IOException e1) { e1.printStackTrace(); log.error(e1.getMessage()); new Popup().error("Backup could not be saved.\nError message: " + e1.getMessage()).show(); } } }); }
From source file:edu.unc.lib.deposit.fcrepo3.IngestDepositTest.java
private void createJob(String depositUuid, String depositDirectoryPath) throws Exception { // Clone the deposit directory File depositFolder = new File(depositsDirectory, depositUuid); File originalDepositDirectory = new File(getClass().getResource(depositDirectoryPath).toURI()); FileUtils.copyDirectory(originalDepositDirectory, depositFolder); job = new IngestDeposit("jobuuid", depositUuid); jmsListener = new FinishIngestsMockListener(job); Dataset dataset = TDBFactory.createDataset(); job.setListener(jmsListener);/*from www .j a va 2s.co m*/ setField(job, "dataset", dataset); setField(job, "depositsDirectory", depositsDirectory); setField(job, "jobStatusFactory", jobStatusFactory); setField(job, "depositStatusFactory", depositStatusFactory); setField(job, "client", client); setField(job, "accessClient", accessClient); depositStatus.put(DepositField.containerId.name(), "uuid:destination"); depositStatus.put(DepositField.excludeDepositRecord.name(), "false"); job.init(); Model model = job.getWritableModel(); model.read(new File(depositFolder, "everything.n3").getAbsolutePath()); job.closeModel(); }
From source file:net.java.javabuild.ExecuteMojo.java
private void afterPreSite() throws IOException { File site = new File(BuilderFolders.SITE); if (site.exists()) FileUtils.copyDirectory(site, new File(generatedSiteDirectory, "resources/")); }
From source file:com.diffplug.gradle.pde.CopyJarsUsingProductFile.java
private void copyVersionsOfPlugin(PluginCatalog catalog, String plugin) { if (!catalog.isSupportedPlatform(plugin)) { return;//from w w w. j a v a2 s . co m } Set<Version> versions = catalog.getVersionsFor(plugin); for (Version version : versions) { File source = catalog.getFile(plugin, version); File dest = new File(destination, source.getName()); Errors.rethrow().run(() -> { if (source.isFile()) { FileUtils.copyFile(source, dest); } else { FileUtils.copyDirectory(source, dest); } }); } }
From source file:com.opera.core.systems.util.ProfileUtils.java
/** * //w w w . j a va 2s.com * @param newPrefs * @return true if profile was copied, else false */ public boolean copyProfile(String newPrefs) { if (new File(newPrefs).exists() == false) { return false; } try { FileUtils.copyDirectory(new File(newPrefs), new File(smallPrefsFolder)); } catch (IOException e) { // Ignore // e.printStackTrace(); return false; } return true; }