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


Java FileUtils.copyFile方法代码示例

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


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

示例1: copyFile

import org.codehaus.plexus.util.FileUtils; //导入方法依赖的package包/类
/**
 * Does the actual copy of the file and logging.
 *
 * @param artifact represents the file to copy.
 * @param destFile file name of destination file.
 *
 * @throws MojoExecutionException with a message if an
 *             error occurs.
 */
protected void copyFile ( File artifact, File destFile )
    throws MojoExecutionException
{
    Log theLog = this.getLog();
    try
    {
        theLog.info( "Copying "
            + ( this.outputAbsoluteArtifactFilename ? artifact.getAbsolutePath() : artifact.getName() ) + " to "
            + destFile );
        FileUtils.copyFile( artifact, destFile );

    }
    catch ( Exception e )
    {
        throw new MojoExecutionException( "Error copying artifact from " + artifact + " to " + destFile, e );
    }
}
 
开发者ID:kefik,项目名称:Pogamut3,代码行数:27,代码来源:AbstractDependencyMojo.java

示例2: copyEmoServiceArtifactToWorkingDirectory

import org.codehaus.plexus.util.FileUtils; //导入方法依赖的package包/类
private void copyEmoServiceArtifactToWorkingDirectory() throws MojoExecutionException, MojoFailureException {
    // NOTE: this emo service artifact is an "uberjar" created by the maven-shade-plugin
    final ArtifactItem emoServiceArtifact = new ArtifactItem();
    emoServiceArtifact.setGroupId("com.bazaarvoice.emodb");
    emoServiceArtifact.setArtifactId("emodb-web");
    emoServiceArtifact.setVersion(pluginVersion());

    resolveArtifactItems(asList(emoServiceArtifact));
    final File emoServiceJar = emoServiceArtifact.getResolvedArtifact().getArtifact().getFile();
    try {
        // copy to "emodb.jar" so that we always overwrite any prior
        FileUtils.copyFile(emoServiceJar, new File(emoProcessWorkingDirectory(), "emodb.jar"));
    } catch (IOException e) {
        throw new MojoFailureException("failed to copy: " + emoServiceArtifact, e);
    }
}
 
开发者ID:bazaarvoice,项目名称:emodb,代码行数:17,代码来源:EmoStartMojo.java

示例3: getDependencyFile

import org.codehaus.plexus.util.FileUtils; //导入方法依赖的package包/类
private File getDependencyFile( Artifact artifact, boolean doCopy )
    throws MojoExecutionException
{

    File newLocation =
        new File( this.externalLibDirectory, artifact.getArtifactId() + "."
            + artifact.getArtifactHandler().getExtension() );

    try
    {
        if ( doCopy && !artifact.getFile().isDirectory()
            && ( !newLocation.exists() || newLocation.lastModified() <= artifact.getFile().lastModified() ) )
        {
            FileUtils.copyFile( artifact.getFile(), newLocation );
        }
    }
    catch ( IOException ioe )
    {
        throw new MojoExecutionException( "Unable to copy dependency to staging area.  Could not copy "
            + artifact.getFile() + " to " + newLocation, ioe );
    }

    return newLocation;
}
 
开发者ID:mojohaus,项目名称:maven-native,代码行数:25,代码来源:NativeLinkMojo.java

示例4: addBom

import org.codehaus.plexus.util.FileUtils; //导入方法依赖的package包/类
private void addBom() throws MojoFailureException, IOException {
    getLog().info("Add the bom to the repository");

    String[] groupIdParts = project.getGroupId().split("\\.");

    FileSystem fs = FileSystems.getDefault();
    Path groupIdDir = fs.getPath(repoDir.getAbsolutePath(), groupIdParts);
    Path targetDir = fs.getPath(groupIdDir.toString(), project.getArtifactId(), project.getVersion());
    String fileName = String.format("%s-%s.%s",
            project.getArtifactId(), project.getVersion(), "pom"
    );

    File targetFile = new File(targetDir.toFile(), fileName);

    FileUtils.copyFile(getBomFile(), targetFile);
    getLog().info("Copied the bom to " + targetFile.getAbsolutePath());
}
 
开发者ID:wildfly-swarm,项目名称:wildfly-swarm-fraction-plugin,代码行数:18,代码来源:RepositoryBuilderMojo.java

示例5: execute

import org.codehaus.plexus.util.FileUtils; //导入方法依赖的package包/类
public void execute()
    throws MojoExecutionException, MojoFailureException
{
    File outFile = project.getFile();
    File backupFile = new File( outFile.getParentFile(), outFile.getName() + ".versionsBackup" );

    if ( backupFile.exists() )
    {
        getLog().info( "Restoring " + outFile + " from " + backupFile );
        try
        {
            FileUtils.copyFile( backupFile, outFile );
            FileUtils.forceDelete( backupFile );
        }
        catch ( IOException e )
        {
            throw new MojoExecutionException( e.getMessage(), e );
        }
    }
}
 
开发者ID:mojohaus,项目名称:versions-maven-plugin,代码行数:21,代码来源:RevertMojo.java

示例6: copy

import org.codehaus.plexus.util.FileUtils; //导入方法依赖的package包/类
public void copy(File output, String groupId, String artifactId, String version, String exclusion)
        throws MojoExecutionException {
    output.mkdirs();
    boolean atLeastOne = false;
    for(Artifact artifact: resolve(groupId, artifactId, version, exclusion)) {
        try {
            FileUtils.copyFile(artifact.getFile(), new File(output, artifact.getFile().getName()));
            atLeastOne = true;
        } catch (IOException e) {
            throw new MojoExecutionException("could not copy: " + artifact, e);
        }
    }
    if (!atLeastOne) {
        throw new MojoExecutionException("could not resolve: " + groupId + ":" + artifactId + ":" + version);
    }
}
 
开发者ID:torquebox,项目名称:jruby9-maven-plugins,代码行数:17,代码来源:ArtifactHelper.java

示例7: executeWithGems

import org.codehaus.plexus.util.FileUtils; //导入方法依赖的package包/类
@Override
protected void executeWithGems() throws MojoExecutionException,
        ScriptException, IOException {
    final boolean pluginDependenciesOnly;
    switch(type) {
    case archive:
        if (this.pluginDependenciesOnly == null) {
            pluginDependenciesOnly = true;
        }
        else {
            pluginDependenciesOnly = this.pluginDependenciesOnly;
        }
        break;
    default:
        pluginDependenciesOnly = false;
    }
    executeWithGems(pluginDependenciesOnly);

    if (bootstrap != null) {
        FileUtils.copyFile(bootstrap, new File(project.getBuild().getOutputDirectory(),
                                                "jar-bootstrap.rb"));
    }
}
 
开发者ID:torquebox,项目名称:jruby9-maven-plugins,代码行数:24,代码来源:GenerateMojo.java

示例8: run

import org.codehaus.plexus.util.FileUtils; //导入方法依赖的package包/类
@Override
public void run() {
    File target = data.getJavadocFile();
    try {
        FileUtils.copyFile(source, target);
    } catch (IOException ex) {
        ex.printStackTrace();
        target.delete();
    }
    refreshNode();
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:12,代码来源:DependencyNode.java

示例9: copyEmoConfigurationFile

import org.codehaus.plexus.util.FileUtils; //导入方法依赖的package包/类
private void copyEmoConfigurationFile() throws MojoExecutionException, IOException {
    if (StringUtils.isBlank(emoConfigurationFile)) {
        copyDefaultEmoConfigurationFile();
    } else {
        try {
            // copy configuration file to well-known emodb config directory and filename "config.yaml"
            FileUtils.copyFile(new File(emoConfigurationFile), new File(emoConfigurationDirectory(), "config.yaml"));
        } catch (Exception e) {
            throw new MojoExecutionException("failed to copy configuration file from " + emoConfigurationFile, e);
        }
    }
}
 
开发者ID:bazaarvoice,项目名称:emodb,代码行数:13,代码来源:EmoStartMojo.java

示例10: copyDdlConfigurationFile

import org.codehaus.plexus.util.FileUtils; //导入方法依赖的package包/类
private void copyDdlConfigurationFile() throws MojoExecutionException, IOException {
    if (StringUtils.isBlank(ddlConfigurationFile)) {
        copyDefaultDdlConfigurationFile();
    } else {
        try {
            // copy configuration file to well-known emodb DDL config directory and filename "config-ddl.yaml"
            FileUtils.copyFile(new File(ddlConfigurationFile), new File(emoConfigurationDirectory(), "config-ddl.yaml"));
        } catch (Exception e) {
            throw new MojoExecutionException("failed to copy configuration file from " + ddlConfigurationFile, e);
        }
    }
}
 
开发者ID:bazaarvoice,项目名称:emodb,代码行数:13,代码来源:EmoStartMojo.java

示例11: makeBackup

import org.codehaus.plexus.util.FileUtils; //导入方法依赖的package包/类
/**
 * gestice i backup di un file
 *
 * @param fileName nome del file che si vuole backuppare
 */
public static void makeBackup(String fileName) {
    try {
        File original = new File(fileName);
        if (original.exists()) {
            String localPath = original.getParent() + "/backup";
            File lp = new File(localPath);
            if (!lp.exists()) {
                lp.mkdirs();
            }
            String savingFileName = localPath + "/" + original.getName();
            String pattern = savingFileName;
            long oldestTime = System.currentTimeMillis();
            for (int i = 0; i < 20; i++) {
                String fn = pattern + "." + i + ".bck";
                File back = new File(fn);
                if (!back.exists()) {
                    savingFileName = fn;
                    break;
                } else if (back.lastModified() < oldestTime) {
                    oldestTime = back.lastModified();
                    savingFileName = back.getAbsolutePath();
                }
            }
            FileUtils.copyFile(original, new File(savingFileName));
        }
    } catch (Exception e) {
        LogGui.printException(e);
    }
}
 
开发者ID:fiohol,项目名称:theSemProject,代码行数:35,代码来源:GuiUtils.java

示例12: copyMissingContent

import org.codehaus.plexus.util.FileUtils; //导入方法依赖的package包/类
/**
 * Copies all content (files and directories) from the source directory to the target directory, except content
 * that already exists in the target directory (same name and path), in other words it does not override any
 * existing content
 *
 * <p>
 * Files from the source directory can be excluded from the copying by setting one or more patterns in the
 * source excludes list
 * </p>
 *
 * @param sourceDirectory directory to copy content from
 * @param targetDirectory directory to copy content to
 * @param sourceExcludes list of patterns to match on for source exclusions
 * @throws IOException
 */
public static void copyMissingContent(File sourceDirectory, File targetDirectory, List<String> sourceExcludes)
        throws IOException {
    String[] copyExcludes = null;

    if ((sourceExcludes != null) && !sourceExcludes.isEmpty()) {
        copyExcludes = new String[sourceExcludes.size()];

        copyExcludes = sourceExcludes.toArray(copyExcludes);
    }

    List<String> sourceDirectoryContents = getDirectoryContents(sourceDirectory, null, copyExcludes);
    List<String> targetDirectoryContents = getDirectoryContents(targetDirectory, null, null);

    for (String sourceContent : sourceDirectoryContents) {
        if (targetDirectoryContents.contains(sourceContent)) {
            continue;
        }

        // copy file to target
        File sourceFile = new File(sourceDirectory, sourceContent);
        File targetFile = new File(targetDirectory, sourceContent);

        if (sourceFile.isDirectory()) {
            targetFile.mkdir();
        } else {
            FileUtils.copyFile(sourceFile, targetFile);
        }
    }
}
 
开发者ID:kuali,项目名称:kc-rice,代码行数:45,代码来源:ThemeBuilderUtils.java

示例13: copyJars

import org.codehaus.plexus.util.FileUtils; //导入方法依赖的package包/类
public void copyJars() throws IOException {
    for(Artifact a: artifacts) {
        if (!a.getScope().equals("system")) {
            File targetFile = new File(target, a.getGroupId().replace('.', '/') + "/" +
                                               a.getArtifactId() + "/" +
                                               a.getVersion() + "/" +
                                               a.getArtifactId() + "-" + a.getVersion() + "." + a.getType());
            FileUtils.copyFile(a.getFile(), targetFile);
        }
    }
}
 
开发者ID:torquebox,项目名称:jruby9-maven-plugins,代码行数:12,代码来源:JarDependencies.java

示例14: copyExternalFile

import org.codehaus.plexus.util.FileUtils; //导入方法依赖的package包/类
private void copyExternalFile( File from, File to )
    throws DaemonGeneratorException
{
    try
    {
        from.getParentFile().mkdirs();
        FileUtils.copyFile( from, to );
    }
    catch ( IOException e )
    {
        throw new DaemonGeneratorException( "Could not copy external file: " + from, e );
    }

}
 
开发者ID:mojohaus,项目名称:appassembler,代码行数:15,代码来源:JavaServiceWrapperDaemonGenerator.java

示例15: copyFile

import org.codehaus.plexus.util.FileUtils; //导入方法依赖的package包/类
/**
 * {@inheritDoc}
 */
public void copyFile( File sourceFile, File targetFile )
        throws MojoExecutionException
{
    makeDirectoryIfNecessary( targetFile.getParentFile() );
    try
    {
        FileUtils.copyFile( sourceFile, targetFile );
    }
    catch ( IOException e )
    {
        throw new MojoExecutionException( "Could not copy file " + sourceFile + " to " + targetFile, e );
    }
}
 
开发者ID:mojohaus,项目名称:webstart,代码行数:17,代码来源:DefaultIOUtil.java


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