List of usage examples for org.apache.commons.io FileUtils copyDirectoryToDirectory
public static void copyDirectoryToDirectory(File srcDir, File destDir) throws IOException
From source file:com.athomas.androidkickstartr.util.LibraryHelper.java
private void copyLibraryToProject(String lib) { try {//w ww. j a va 2 s .com File library = fileHelper.getLibraryFile(lib); File projectDir = fileHelper.getFinalDir(); FileUtils.copyDirectoryToDirectory(library, projectDir); } catch (IOException e) { LOGGER.error("a problem occured during the copy of the library " + lib, e); } }
From source file:com.withbytes.tentaculo.traverser.windows.WindowsTraverser.java
public boolean backup(String sourcePath, IPathTranslator translator, String backupPath) throws TentaculoException { File source = new File(translator.translatePath(sourcePath)); File destination = new File(backupPath); try {//from ww w . j av a 2 s . c om if (!source.exists()) { return false; } if (source.isFile()) { FileUtils.copyFileToDirectory(source, destination); } if (source.isDirectory()) { FileUtils.copyDirectoryToDirectory(source, destination); } } catch (IOException ex) { return false; } return true; }
From source file:de.uzk.hki.da.cb.UpdateMetadataActionXMPTests.java
@Before public void setUp() throws Exception { FileUtils.copyDirectoryToDirectory(new File("src/main/xslt"), new File("conf/")); Object obj = TESTHelper.setUpObject("123", workAreaRootPath); DAFile daf1 = new DAFile(obj.getLatestPackage(), _1_A_REP, "a.txt"); DAFile daf2 = new DAFile(obj.getLatestPackage(), _1_B_REP, "a.txt"); DAFile daf3 = new DAFile(obj.getLatestPackage(), _1_B_REP, "a.xmp"); DAFile daf4 = new DAFile(obj.getLatestPackage(), "dip/institution", "hasha.txt"); DAFile daf5 = new DAFile(obj.getLatestPackage(), "dip/public", "hasha.txt"); DAFile daf6 = new DAFile(obj.getLatestPackage(), "dip/public", "hashb.txt"); DAFile daf7 = new DAFile(obj.getLatestPackage(), "dip/institution", "hashb.txt"); DAFile daf8 = new DAFile(obj.getLatestPackage(), _1_A_REP, "b.txt"); DAFile daf9 = new DAFile(obj.getLatestPackage(), _1_B_REP, "b.txt"); DAFile daf10 = new DAFile(obj.getLatestPackage(), _1_B_REP, "b.xmp"); Event evt1 = new Event(); evt1.setSource_file(daf2);//from ww w . j a v a 2s . c o m evt1.setTarget_file(daf4); evt1.setType("CONVERT"); Event evt2 = new Event(); evt2.setSource_file(daf2); evt2.setTarget_file(daf5); evt2.setType("CONVERT"); Event evt3 = new Event(); evt3.setSource_file(daf9); evt3.setTarget_file(daf6); evt3.setType("CONVERT"); Event evt4 = new Event(); evt4.setSource_file(daf9); evt4.setTarget_file(daf7); evt4.setType("CONVERT"); Event evt5 = new Event(); evt5.setSource_file(daf1); evt5.setTarget_file(daf2); evt5.setType("CONVERT"); Event evt6 = new Event(); evt6.setSource_file(daf8); evt6.setTarget_file(daf9); evt6.setType("CONVERT"); obj.getLatestPackage().getFiles().add(daf1); obj.getLatestPackage().getFiles().add(daf2); obj.getLatestPackage().getFiles().add(daf3); obj.getLatestPackage().getFiles().add(daf4); obj.getLatestPackage().getFiles().add(daf5); obj.getLatestPackage().getFiles().add(daf6); obj.getLatestPackage().getFiles().add(daf7); obj.getLatestPackage().getFiles().add(daf8); obj.getLatestPackage().getFiles().add(daf9); obj.getLatestPackage().getFiles().add(daf10); obj.getLatestPackage().getEvents().add(evt1); obj.getLatestPackage().getEvents().add(evt2); obj.getLatestPackage().getEvents().add(evt3); obj.getLatestPackage().getEvents().add(evt4); obj.getLatestPackage().getEvents().add(evt5); obj.getLatestPackage().getEvents().add(evt6); UpdateMetadataAction action = new UpdateMetadataAction(); HashMap<String, String> xpaths = new HashMap<String, String>(); xpaths.put("XMP", "//rdf:Description/@rdf:about"); action.setXpathsToUrls(xpaths); HashMap<String, String> nsMap = new HashMap<String, String>(); action.setNamespaces(nsMap); Job job = new Job(); job.setId(1); action.setMtds(mtds); action.setObject(obj); action.setJob(job); action.setRepNames(new String[] { "dip/public", "dip/institution" }); obj.setMetadata_file("XMP.rdf"); obj.setPackage_type("XMP"); Map<String, String> dcMappings = new HashMap<String, String>(); dcMappings.put("XMP", "conf/xslt/dc/xmp_to_dc.xsl"); action.setDcMappings(dcMappings); action.implementation(); }
From source file:com.google.gwt.site.markdown.MarkupWriter.java
public void copyImageDirs(MDParent mdParent) throws TranslaterException { String destDirPath = rootFile.getPath() + File.separator + mdParent.getRelativePath(); File destDir = new File(destDirPath); ensureDirectory(destDir);//from ww w . ja va2 s . com List<File> imageDirs = mdParent.getImageDirs(); for (File srcDir : imageDirs) { try { FileUtils.copyDirectoryToDirectory(srcDir, destDir); } catch (IOException e) { throw new TranslaterException("can not copy image folder'" + srcDir + "'"); } } }
From source file:com.blackducksoftware.tools.scmconnector.integrations.filesystem.FileSystemConnector.java
@Override public int sync() { if (repoURL != null) { File sourceLocation = new File(repoURL); File targetLocation = new File(getFinalSourceDirectory()); if (!sourceLocation.exists()) { log.error("Unable to find repository location: " + repoURL); return -1; }// w ww . j a va 2s . c om boolean created = createTargetLocation(targetLocation); if (!created) { return -1; } try { log.info("Copying source: " + sourceLocation); log.info("To destination: " + targetLocation); FileUtils.copyDirectoryToDirectory(sourceLocation, targetLocation); log.info("Finished copying"); } catch (IOException ioe) { log.error("Unable to copy directory: " + ioe.getMessage()); return -1; } // return copyDirectory(targetLocation, destinationLocation)); } return 0; }
From source file:administraScan.OrganizaDirectorios.java
public void copiarCompletos() throws IOException { FileUtils Files = new FileUtils(); AdministraScan adm = new AdministraScan(); File origen;/*from w ww. ja v a 2 s . c om*/ File destino; File f = new File(conf.carpetaCT); ArrayList<String> cts = new ArrayList<>(Arrays.asList(f.list())); for (String ct : cts) { String dirCT = conf.carpetaCT + ct.trim(); File dir_expedientes = new File(dirCT); ArrayList<String> curps = new ArrayList<>(Arrays.asList(dir_expedientes.list())); for (String curp : curps) { String dircurp = dirCT + "\\" + curp.trim(); File doc = new File(dircurp); ArrayList<String> documentos = new ArrayList<>(Arrays.asList(doc.list())); ArrayList<String> claves = adm.RetornaCT(documentos); ArrayList<String> obli_cedula = new ArrayList<>(Arrays.asList(conf.DOC_R)); obli_cedula.remove("CUGE"); boolean completo_cedula = claves.containsAll(obli_cedula) && (claves.contains("CPL") || claves.contains("CPM") || claves.contains("CPD")) && !claves.contains("CUGE"); if (claves.containsAll(conf.OBLIGATORIOS) || completo_cedula) { String clave = ""; String nombre_ss = ""; clave = ct.substring(3, 5); this.conectarbd(); String consultaDescripcionSS = "Select descripcion from cg_nivel_educativo where nivel_educativo = ?"; try { PreparedStatement SPreparada; SPreparada = connection.prepareStatement(consultaDescripcionSS); SPreparada.setString(1, clave); ResultSet resultadoDescripcion = SPreparada.executeQuery(); if (resultadoDescripcion.next()) { nombre_ss = resultadoDescripcion.getString("descripcion").trim(); } SPreparada.close(); connection.close(); } catch (SQLException ex) { Logger.getLogger(OrganizaDirectorios.class.getName()).log(Level.SEVERE, null, ex); } String ruta_destino = conf.carpetaRemota + "completos\\" + nombre_ss + "\\" + ct.trim(); origen = new File(dircurp); destino = new File(ruta_destino); File destino_final = new File(ruta_destino + "\\" + curp.trim()); if (!destino_final.exists()) { Files.copyDirectoryToDirectory(doc, destino); System.out.println( "Movi carpeta: " + doc.getAbsolutePath() + " a " + destino_final.getAbsolutePath()); } } } } }
From source file:com.igormaznitsa.mvngolang.GolangMvnInstallMojo.java
private void safeCopyDirectory(@Nullable final String src, @Nonnull final File dst) throws IOException { if (src == null || src.isEmpty()) { return;/*from ww w . j a va2 s. c o m*/ } final File srcFile = new File(src); if (srcFile.isDirectory()) { if (getLog().isDebugEnabled()) { getLog().debug(String.format("Copying %s => %s", srcFile.getAbsolutePath(), dst.getAbsolutePath())); } FileUtils.copyDirectoryToDirectory(srcFile, dst); } }
From source file:com.aniruddhc.acemusic.player.AsyncTasks.AsyncCopyMoveTask.java
@Override protected Boolean doInBackground(String... params) { try {/* w w w .j a v a 2s . co m*/ if (mSourceFile.getCanonicalPath() == mDestinationFile.getCanonicalPath()) { Toast.makeText(mContext, R.string.source_target_same, Toast.LENGTH_LONG).show(); return false; } } catch (Exception e) { return false; } if (mSourceFile.isDirectory()) { try { if (mShouldMove) FileUtils.moveDirectoryToDirectory(mSourceFile, mDestinationFile, true); else FileUtils.copyDirectoryToDirectory(mSourceFile, mDestinationFile); } catch (Exception e) { return false; } } else { try { if (mShouldMove) FileUtils.moveFileToDirectory(mSourceFile, mDestinationFile, true); else FileUtils.copyFile(mSourceFile, mDestinationFile); } catch (Exception e) { return false; } } return true; }
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. java2 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:com.thoughtworks.go.server.DevelopmentServer.java
private static void copyDbFiles() throws IOException { FileUtils.copyDirectoryToDirectory(new File("db/migrate/h2deltas"), new File("db/")); if (!new File("db/h2db/cruise.h2.db").exists()) { FileUtils.copyDirectoryToDirectory(new File("db/dbtemplate/h2db"), new File("db/")); }/*from ww w . j a v a 2 s . c o m*/ }