/** * Copy a directory to an other one. * * @param sourceDirectory the source dir * @param destinationDirectory the target dir * @throws IOException if any */ public static void copyDirectory( File sourceDirectory, File destinationDirectory ) throws IOException { copyDirectory( sourceDirectory, destinationDirectory, "**", null ); }
public Object execute(final CommandContext context) throws Exception { assert context != null; File sourceFile = fileSystem.resolveFile( source ); File targetFile = fileSystem.resolveFile( target ); if (sourceFile.isDirectory()) { // for cp -r /tmp/foo /home : we must create first the directory /home/foo targetFile = new File(targetFile, sourceFile.getName()); if (!targetFile.exists()) { targetFile.mkdirs(); } if (recursive) { FileUtils.copyDirectoryStructure(sourceFile, targetFile); } else { FileUtils.copyDirectory(sourceFile, targetFile); } } else { if (targetFile.isDirectory()) { FileUtils.copyFileToDirectory(sourceFile, targetFile); } else { FileUtils.copyFile(sourceFile, targetFile); } } return Result.SUCCESS; }
private void copyNativeSourceFiles() throws MojoExecutionException { try { FileUtils.copyDirectory(nativeSourceDirectory, generatedNativeSourceDirectory); } catch (Exception e) { throw new MojoExecutionException("Copy of Native source failed: "+e, e); } }
public static void copyDirectory( File sourceDirectory, File destinationDirectory, String includes, String excludes ) throws IOException { if ( !sourceDirectory.exists() ) { return; } List files = getFiles( sourceDirectory, includes, excludes ); for ( Iterator i = files.iterator(); i.hasNext(); ) { File file = (File) i.next(); copyFileToDirectory( file, destinationDirectory ); } }
FileUtils.copyDirectory( new File( project.getBasedir(), "src/main/config" ), new File( project.getBuild().getDirectory() ), "*.exe.config", null );
@Override public void execute() { if (skip) { return; } // Make sure we are configured correctly Assert.notNull(srcDir, "srcDir is null"); Assert.notNull(dstDir, "dstDir is null"); // Source directory has to exist already. We'll create destination directory if necessary Assert.isExistingDir(srcDir, "srcDir is not an existing directory"); try { // Null safe conversion of the lists to CSV String includesCSV = StringUtils.trimToNull(CollectionUtils.getCSV(includes)); String excludesCSV = StringUtils.trimToNull(CollectionUtils.getCSV(excludes)); // Make sure we can create the destination directory FileUtils.forceMkdir(dstDir); // Show what we are up to logCopy(); // Copy files from src to dst FileUtils.copyDirectory(srcDir, dstDir, includesCSV, excludesCSV); } catch (IOException e) { throw new IllegalStateException("Unexpected IO error", e); } }
FileUtils.copyDirectory( resources, sourceWithSpace );
FileUtils.copyDirectory( resources, sourceWithSpace );