本文整理了Java中org.apache.maven.shared.utils.io.FileUtils.copyFile()
方法的一些代码示例,展示了FileUtils.copyFile()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。FileUtils.copyFile()
方法的具体详情如下:
包路径:org.apache.maven.shared.utils.io.FileUtils
类名称:FileUtils
方法名:copyFile
[英]Copy file from source to destination. The directories up to destination
will be created if they don't already exist. destination
will be overwritten if it already exists.
[中]将文件从源复制到目标。如果目录不存在,则将创建最高达destination
的目录。destination
如果已经存在,将被覆盖。
代码示例来源:origin: fabric8io/docker-maven-plugin
public File createChangedFilesArchive(List<AssemblyFiles.Entry> entries, File assemblyDirectory,
String imageName, MojoParameters mojoParameters)
throws MojoExecutionException {
BuildDirs dirs = createBuildDirs(imageName, mojoParameters);
try {
File archive = new File(dirs.getTemporaryRootDirectory(), "changed-files.tar");
File archiveDir = createArchiveDir(dirs);
for (AssemblyFiles.Entry entry : entries) {
File dest = prepareChangedFilesArchivePath(archiveDir,entry.getDestFile(),assemblyDirectory);
FileUtils.copyFile(entry.getSrcFile(), dest);
}
return createChangedFilesTarBall(archive, archiveDir);
} catch (IOException exp) {
throw new MojoExecutionException("Error while creating " + dirs.getTemporaryRootDirectory() +
"/changed-files.tar: " + exp);
}
}
代码示例来源:origin: org.apache.maven.shared/maven-shared-utils
/**
* <b>If wrappers is null or empty, the file will be copy only if to.lastModified() < from.lastModified()</b>
*
* @param from the file to copy
* @param to the destination file
* @param encoding the file output encoding (only if wrappers is not empty)
* @param wrappers array of {@link FilterWrapper}
* @throws IOException if an IO error occurs during copying or filtering
*/
public static void copyFile( @Nonnull File from, @Nonnull File to, @Nullable String encoding,
@Nullable FilterWrapper... wrappers )
throws IOException
{
copyFile( from, to, encoding, wrappers, false );
}
代码示例来源:origin: org.apache.maven.shared/maven-shared-utils
/**
* Copy file from source to destination only if source timestamp is later than the destination timestamp.
* The directories up to <code>destination</code> will be created if they don't already exist.
* <code>destination</code> will be overwritten if it already exists.
*
* @param source An existing non-directory <code>File</code> to copy bytes from.
* @param destination A non-directory <code>File</code> to write bytes to (possibly
* overwriting).
* @return true if no problem occured
* @throws IOException if <code>source</code> does not exist, <code>destination</code> cannot be
* written to, or an IO error occurs during copying.
*/
private static boolean copyFileIfModified( @Nonnull final File source, @Nonnull final File destination )
throws IOException
{
if ( destination.lastModified() < source.lastModified() )
{
copyFile( source, destination );
return true;
}
return false;
}
代码示例来源:origin: org.apache.maven.shared/maven-shared-utils
/**
* Copy file from source to destination. If <code>destinationDirectory</code> does not exist, it
* (and any parent directories) will be created. If a file <code>source</code> in
* <code>destinationDirectory</code> exists, it will be overwritten.
*
* @param source An existing <code>File</code> to copy.
* @param destinationDirectory A directory to copy <code>source</code> into.
* @throws java.io.FileNotFoundException if <code>source</code> isn't a normal file.
* @throws IllegalArgumentException if <code>destinationDirectory</code> isn't a directory.
* @throws IOException if <code>source</code> does not exist, the file in
* <code>destinationDirectory</code> cannot be written to, or an IO error
* occurs during copying.
*/
public static void copyFileToDirectory( @Nonnull final File source, @Nonnull final File destinationDirectory )
throws IOException
{
if ( destinationDirectory.exists() && !destinationDirectory.isDirectory() )
{
throw new IllegalArgumentException( "Destination is not a directory" );
}
copyFile( source, new File( destinationDirectory, source.getName() ) );
}
代码示例来源:origin: org.apache.maven.shared/maven-shared-utils
copyFile( from, to );
if ( !deleteLegacyStyle( from ) )
代码示例来源:origin: org.apache.maven.shared/maven-verifier
FileUtils.copyFile( resourceFile, destination );
代码示例来源:origin: org.apache.maven.shared/maven-shared-utils
copyFile( from, to );
代码示例来源:origin: org.apache.maven.shared/maven-filtering
private void filterFile( @Nonnull File from, @Nonnull File to, @Nullable String encoding,
@Nullable List<FilterWrapper> wrappers )
throws IOException, MavenFilteringException
{
if ( wrappers != null && wrappers.size() > 0 )
{
Reader fileReader = null;
Writer fileWriter = null;
try
{
fileReader = getFileReader( encoding, from );
fileWriter = getFileWriter( encoding, to );
Reader src = readerFilter.filter( fileReader, true, wrappers );
IOUtil.copy( src, fileWriter );
}
finally
{
IOUtil.close( fileReader );
IOUtil.close( fileWriter );
}
}
else
{
if ( to.lastModified() < from.lastModified() )
{
FileUtils.copyFile( from, to );
}
}
}
代码示例来源:origin: org.jolokia/docker-maven-plugin
public File createChangedFilesArchive(List<AssemblyFiles.Entry> entries, File assemblyDirectory,
String imageName, MojoParameters mojoParameters)
throws MojoExecutionException {
BuildDirs dirs = createBuildDirs(imageName, mojoParameters);
try {
File archive = new File(dirs.getTemporaryRootDirectory(), "changed-files.tar");
File archiveDir = createArchiveDir(dirs);
for (AssemblyFiles.Entry entry : entries) {
File dest = prepareChangedFilesArchivePath(archiveDir,entry.getDestFile(),assemblyDirectory);
FileUtils.copyFile(entry.getSrcFile(), dest);
}
return createChangedFilesTarBall(archive, archiveDir);
} catch (IOException exp) {
throw new MojoExecutionException("Error while creating " + dirs.getTemporaryRootDirectory() +
"/changed-files.tar: " + exp);
}
}
代码示例来源:origin: org.apache.maven.shared/maven-filtering
/** {@inheritDoc} */
public void copyFile( File from, File to, boolean filtering, List<FileUtils.FilterWrapper> filterWrappers,
String encoding, boolean overwrite )
throws MavenFilteringException
{
try
{
if ( filtering )
{
if ( getLogger().isDebugEnabled() )
{
getLogger().debug( "filtering " + from.getPath() + " to " + to.getPath() );
}
filterFile( from, to, encoding, filterWrappers );
}
else
{
if ( getLogger().isDebugEnabled() )
{
getLogger().debug( "copy " + from.getPath() + " to " + to.getPath() );
}
FileUtils.copyFile( from, to, encoding, new FileUtils.FilterWrapper[0], overwrite );
}
buildContext.refresh( to );
}
catch ( IOException e )
{
throw new MavenFilteringException( e.getMessage(), e );
}
}
代码示例来源:origin: org.apache.maven.plugins/maven-assembly-plugin
repositoryManager.getPathForLocalArtifact( buildingRequest, a ) );
FileUtils.copyFile( a.getFile(), targetFile );
内容来源于网络,如有侵权,请联系作者删除!