当前位置: 首页>>代码示例>>Java>>正文


Java FileUtils.copyFileToDirectory方法代码示例

本文整理汇总了Java中org.codehaus.plexus.util.FileUtils.copyFileToDirectory方法的典型用法代码示例。如果您正苦于以下问题:Java FileUtils.copyFileToDirectory方法的具体用法?Java FileUtils.copyFileToDirectory怎么用?Java FileUtils.copyFileToDirectory使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.codehaus.plexus.util.FileUtils的用法示例。


在下文中一共展示了FileUtils.copyFileToDirectory方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: execution

import org.codehaus.plexus.util.FileUtils; //导入方法依赖的package包/类
@Override
protected TOExecutionResult execution(File transformedAppFolder, TransformationContext transformationContext) {
    File fileFrom = getAbsoluteFile(transformedAppFolder, transformationContext);
    File fileTo = getFileTo(transformedAppFolder, transformationContext);
    TOExecutionResult result = null;

    // TODO
    // Check if it is really a file and if it exists!

    try {
        String details = String.format("File '%s' has been moved to '%s'", getRelativePath(), getRelativePath(transformedAppFolder, fileTo));
        FileUtils.copyFileToDirectory(fileFrom, fileTo);
        FileUtils.fileDelete(fileFrom.getAbsolutePath());
        result = TOExecutionResult.success(this, details);
    } catch (IOException e) {
        result = TOExecutionResult.error(this, e);
    }

    return result;
}
 
开发者ID:paypal,项目名称:butterfly,代码行数:21,代码来源:MoveFile.java

示例2: execution

import org.codehaus.plexus.util.FileUtils; //导入方法依赖的package包/类
@Override
protected TOExecutionResult execution(File transformedAppFolder, TransformationContext transformationContext) {
    File fileFrom = getAbsoluteFile(transformedAppFolder, transformationContext);
    File fileTo = getFileTo(transformedAppFolder, transformationContext);
    TOExecutionResult result = null;

    try {
        String details = String.format("File '%s' has been copied to '%s'", getRelativePath(), getRelativePath(transformedAppFolder, fileTo));
        FileUtils.copyFileToDirectory(fileFrom, fileTo);
        result = TOExecutionResult.success(this, details);
    } catch (IOException e) {
        result = TOExecutionResult.error(this, e);
    }

    return result;
}
 
开发者ID:paypal,项目名称:butterfly,代码行数:17,代码来源:CopyFile.java

示例3: generateConfdArtefacts

import org.codehaus.plexus.util.FileUtils; //导入方法依赖的package包/类
public static void generateConfdArtefacts(
    PrepareContext context,
    List<TemplateConfig> templates,
    boolean forceDestToLocalFileSystemType,
    Log log
) throws IOException {

    File workingDirectory = context.getWorkingDirectory();

    File templatesDirectory = new File(workingDirectory, TEMPLATES_DIRECTORY);
    File tomlDirectory = new File(workingDirectory, CONF_D_DIRECTORY);

    if (workingDirectory.exists()) {
        FileUtils.deleteDirectory(workingDirectory);
    }

    FileUtils.mkdir(templatesDirectory.getAbsolutePath());
    FileUtils.mkdir(tomlDirectory.getAbsolutePath());
    for (TemplateConfig tc : templates) {
        String tomlBaseName = FileUtils.basename(tc.getSrc().getAbsolutePath()) + TOML_FILE_EXT;
        File tomlFile = new File(tomlDirectory, tomlBaseName);
        writeToml(tomlFile, tc, forceDestToLocalFileSystemType);
        FileUtils.copyFileToDirectory(tc.getSrc(), templatesDirectory);
        warnAboutKeysExcludedByNamespace(tc, context, log);
    }
}
 
开发者ID:nodevops,项目名称:confd-maven-plugin,代码行数:27,代码来源:WorkingDirectoryUtil.java

示例4: processSei

import org.codehaus.plexus.util.FileUtils; //导入方法依赖的package包/类
protected void processSei( String aSei )
    throws MojoExecutionException
{
    getLog().info( "Processing: " + aSei );
    ArrayList<String> args = getWsGenArgs( aSei );
    getLog().info( "jaxws:wsgen args: " + args );
    exec( args );
    if ( metadata != null )
    {
        try
        {
            FileUtils.copyFileToDirectory( metadata, getClassesDir() );
        }
        catch ( IOException ioe )
        {
            throw new MojoExecutionException( ioe.getMessage(), ioe );
        }
    }
}
 
开发者ID:mojohaus,项目名称:jaxws-maven-plugin,代码行数:20,代码来源:AbstractWsGenMojo.java

示例5: doPackaging

import org.codehaus.plexus.util.FileUtils; //导入方法依赖的package包/类
public void doPackaging(PackagingContext context) throws Exception {
	File larsDir = new File(context.getExtensionDirectory(), Constants.DIR_ARCHIVES);
	File jarsDir = new File(context.getExtensionDirectory(), Constants.DIR_JARS);
	
	// copy dependencies in
	Artifact a;
	for (Object aObj : context.getArtifacts()) {
		
		if (aObj instanceof Artifact) {
			a = (Artifact)aObj;
	
			if (a.getType().equals("lar"))
				FileUtils.copyFileToDirectory(a.getFile(), larsDir);
			else if (a.getType().equals("jar"))
				FileUtils.copyFileToDirectory(a.getFile(), jarsDir);
			else if (a.getType().equals("lex"))
				// dont know how to do this better?
				System.out.println("[WARNING] Unable to include "+a.toString()+"");
				//throw new MojoFailureException("Lucee extension dependency "+a.toString()+" not included!", );
		}
	}
	
	if (context.getProject().getPackaging().equals(Constants.LEX_PACKAGING)) {
		File scanDir = context.getOutputDirectory();
		File scanFile;
		for (String file : scanDir.list()) {
			scanFile = new File(scanDir,file);
			if (file.endsWith(".lar")) {
				FileUtils.copyFileToDirectory(scanFile, larsDir);
				scanFile.delete();
			} else if (file.endsWith(".jar")) {
				FileUtils.copyFileToDirectory(scanFile, jarsDir);
				scanFile.delete();
			}
		}
	}
}
 
开发者ID:dajester2013,项目名称:lucee-maven-plugin,代码行数:38,代码来源:CopyDependenciesTask.java

示例6: copyJnlpFiles

import org.codehaus.plexus.util.FileUtils; //导入方法依赖的package包/类
private void copyJnlpFiles()
        throws MavenReportException
{
    if ( !jnlpSourceDirectory.exists() )
    {
        throw new MavenReportException( "jnlpSourceDirectory does not exist" );
    }
    try
    {
        File destinationDirectory = new File( outputDirectory, siteJnlpDirectory );
        List<File> files = FileUtils.getFiles( jnlpSourceDirectory, "**/*", "" );
        for ( File file : files )
        {
            getLog().debug( "Copying " + file + " to " + destinationDirectory );
            String path = file.getAbsolutePath().substring( jnlpSourceDirectory.getAbsolutePath().length() + 1 );
            File destDir = new File( destinationDirectory, path );
            getLog().debug( "Copying " + file + " to " + destDir );
            if ( file.isDirectory() )
            {
                destDir.mkdirs();
            }
            else
            {
                FileUtils.copyFileToDirectory( file, destDir.getParentFile() );
            }
        }
    }
    catch ( IOException e )
    {
        throw new MavenReportException( "Failed to copy jnlp files", e );
    }
}
 
开发者ID:mojohaus,项目名称:webstart,代码行数:33,代码来源:JnlpReportMojo.java

示例7: copyFileToDirectoryIfNecessary

import org.codehaus.plexus.util.FileUtils; //导入方法依赖的package包/类
/**
 * {@inheritDoc}
 */
public boolean copyFileToDirectoryIfNecessary( File sourceFile, File targetDirectory )
        throws MojoExecutionException
{

    if ( sourceFile == null )
    {
        throw new IllegalArgumentException( "sourceFile is null" );
    }

    File targetFile = new File( targetDirectory, sourceFile.getName() );

    boolean shouldCopy = shouldCopyFile( sourceFile, targetFile );

    if ( shouldCopy )
    {
        try
        {
            FileUtils.copyFileToDirectory( sourceFile, targetDirectory );
        }
        catch ( IOException e )
        {
            throw new MojoExecutionException(
                    "Could not copy file " + sourceFile + " to directory " + targetDirectory, e );
        }
    }
    else
    {
        getLogger().debug(
                "Source file hasn't changed. Do not overwrite " + targetFile + " with " + sourceFile + "." );

    }

    return shouldCopy;
}
 
开发者ID:mojohaus,项目名称:webstart,代码行数:38,代码来源:DefaultIOUtil.java

示例8: execute

import org.codehaus.plexus.util.FileUtils; //导入方法依赖的package包/类
/**
    * 
    */    
public void execute() throws MojoExecutionException, MojoFailureException 
{
    if ( puXMLFile == null || !FileUtils.fileExists( puXMLFile ) )
    {
        throw new MojoExecutionException( "missing pu.xml file" );
    }
        
    if ( warFile == null || !FileUtils.fileExists( warFile ) )
    {
        throw new MojoExecutionException( "missing war file" );
    }
    
    try
       {
        String puTargetDir = serverDirectory + File.separator + "META-INF" + File.separator + "spring";
        String libTargetDir = serverDirectory + File.separator + "lib";
        
        FileUtils.mkdir( serverDirectory );	        
        FileUtils.mkdir( puTargetDir );
        FileUtils.mkdir( libTargetDir );
        
           FileUtils.copyFileToDirectory( new File( puXMLFile ), new File( puTargetDir ) );
           FileUtils.copyFileToDirectory( new File( warFile ), new File( serverDirectory ) );
           
           
            for (Iterator artifactIterator = pluginArtifacts.iterator(); artifactIterator.hasNext();) 
            {
               Artifact artifact = (Artifact) artifactIterator.next();
               if (artifact.getGroupId().equals("org.mortbay.jetty") ) 
               {
                   FileUtils.copyFileToDirectory( artifact.getFile().getPath(), libTargetDir );
               }
            }
            
            jarArchiver.addDirectory( new File(serverDirectory) );
            jarArchiver.setDestFile( new File(artifactName) );
            jarArchiver.createArchive();
       }
       catch ( IOException ioe )
       {
           throw new MojoExecutionException( "unable to assemble",ioe );
       }
       catch ( ArchiverException ae )
       {
           throw new MojoExecutionException( "unable to assembly jar", ae );
       }
}
 
开发者ID:iMartinezMateu,项目名称:openbravo-pos,代码行数:51,代码来源:JOSGeneratePUMojo.java

示例9: copyDirectoryStructureWithIO

import org.codehaus.plexus.util.FileUtils; //导入方法依赖的package包/类
private void copyDirectoryStructureWithIO( final File sourceDirectory, final File destinationDirectory,
                                           final File rootDestinationDirectory )
                                               throws IOException
{
    preconditionsCopyDirectoryStructure( sourceDirectory, destinationDirectory, rootDestinationDirectory );
    File[] files = sourceDirectory.listFiles();
    if ( files == null )
    {
        return;
    }
    String sourcePath = sourceDirectory.getAbsolutePath();

    for ( File file : files )
    {
        if ( file.equals( rootDestinationDirectory ) )
        {
            // We don't copy the destination directory in itself
            continue;
        }

        String dest = file.getAbsolutePath();

        dest = dest.substring( sourcePath.length() + 1 );

        File destination = new File( destinationDirectory, dest );

        if ( file.isFile() )
        {
            destination = destination.getParentFile();

            if ( isFileDifferent( file, destination ) )
            {
                copied++;
                FileUtils.copyFileToDirectory( file, destination );
            }
        }
        else if ( file.isDirectory() )
        {
            if ( !destination.exists() && !destination.mkdirs() )
            {
                throw new IOException( "Could not create destination directory '" + destination.getAbsolutePath()
                    + "'." );
            }

            copyDirectoryStructureWithIO( file, destination, rootDestinationDirectory );
        }
        else
        {
            throw new IOException( "Unknown file type: " + file.getAbsolutePath() );
        }
    }
}
 
开发者ID:mojohaus,项目名称:templating-maven-plugin,代码行数:53,代码来源:AbstractFilterSourcesMojo.java


注:本文中的org.codehaus.plexus.util.FileUtils.copyFileToDirectory方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。