本文整理了Java中org.codehaus.plexus.util.FileUtils.copyFile()
方法的一些代码示例,展示了FileUtils.copyFile()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。FileUtils.copyFile()
方法的具体详情如下:
包路径:org.codehaus.plexus.util.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: org.codehaus.plexus/plexus-utils
/**
* <b>If wrappers is null or empty, the file will be copy only if {@code 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( File from, File to, String encoding, FilterWrapper[] wrappers )
throws IOException
{
copyFile( from, to, encoding, wrappers, false );
}
代码示例来源:origin: org.codehaus.plexus/plexus-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( final File source, 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.codehaus.plexus/plexus-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.
*/
public static boolean copyFileIfModified( final File source, final File destination )
throws IOException
{
if ( isSourceNewerThanDestination( source, destination ) )
{
copyFile( source, destination );
return true;
}
return false;
}
代码示例来源:origin: org.codehaus.plexus/plexus-utils
copyFile( from, to );
if ( !from.delete() )
代码示例来源:origin: apache/maven
public void merge( File current, File result )
throws RepositoryException
{
try
{
if ( current.exists() )
{
FileUtils.copyFile( current, result );
}
ArtifactRepository localRepo = new MetadataRepository( result );
metadata.storeInLocalRepository( localRepo, localRepo );
merged = true;
}
catch ( Exception e )
{
throw new RepositoryException( e.getMessage(), e );
}
}
代码示例来源:origin: org.codehaus.plexus/plexus-utils
copyFile( from, to );
代码示例来源:origin: apache/maven
FileUtils.copyFile( tempChecksumFile, checksumFile );
if ( !tempChecksumFile.delete() )
代码示例来源:origin: apache/maven
public void storeInLocalRepository( ArtifactRepository localRepository, ArtifactRepository remoteRepository )
throws RepositoryMetadataStoreException
{
File destination =
new File( localRepository.getBasedir(), localRepository.pathOfLocalRepositoryMetadata( this,
remoteRepository ) );
// ----------------------------------------------------------------------------
// I'm fully aware that the file could just be moved using File.rename but
// there are bugs in various JVM that have problems doing this across
// different filesystem. So we'll incur the small hit to actually copy
// here and be safe. jvz.
// ----------------------------------------------------------------------------
try
{
FileUtils.copyFile( file, destination );
}
catch ( IOException e )
{
throw new RepositoryMetadataStoreException( "Error copying POM to the local repository.", e );
}
}
代码示例来源:origin: org.apache.maven/maven-project
public void storeInLocalRepository( ArtifactRepository localRepository,
ArtifactRepository remoteRepository )
throws RepositoryMetadataStoreException
{
File f = transformedFile == null ? originalFile : transformedFile;
if ( f == null )
{
return;
}
File destination = new File( localRepository.getBasedir(),
localRepository.pathOfLocalRepositoryMetadata( this, remoteRepository ) );
// ----------------------------------------------------------------------------
// I'm fully aware that the file could just be moved using File.rename but
// there are bugs in various JVM that have problems doing this across
// different filesystem. So we'll incur the small hit to actually copy
// here and be safe. jvz.
// ----------------------------------------------------------------------------
try
{
FileUtils.copyFile( f, destination );
}
catch ( IOException e )
{
throw new RepositoryMetadataStoreException( "Error copying POM to the local repository.", e );
}
}
代码示例来源:origin: org.apache.maven.plugin-testing/maven-plugin-testing-harness
public static void cp( File basedir, String from, String to )
throws IOException
{
// TODO ensure destination lastModified timestamp changes
FileUtils.copyFile( new File( basedir, from ), new File( basedir, to ) );
}
代码示例来源:origin: apache/maven
FileUtils.copyFile( temp, destination );
代码示例来源:origin: KylinOLAP/Kylin
private void deployJobConfToEtc() throws IOException {
File src = new File(SANDBOX_TEST_DATA, JobEngineConfig.HADOOP_JOB_CONF_FILENAME + ".xml");
File dst = new File("/etc/kylin", src.getName());
FileUtils.copyFile(src, dst);
}
代码示例来源:origin: org.apache.maven.plugin-testing/maven-plugin-testing-harness
FileUtils.copyFile( srcFile, theFile );
代码示例来源:origin: KylinOLAP/Kylin
public static void deployJobJars() throws IOException {
Pair<File, File> files = getJobJarFiles();
File originalJobJar = files.getFirst();
File originalCoprocessorJar = files.getSecond();
String jobJarPath = config().getKylinJobJarPath();
if (StringUtils.isEmpty(jobJarPath)) {
throw new RuntimeException("deployJobJars cannot find job jar");
}
File targetJobJar = new File(jobJarPath);
File jobJarRenamedAsTarget = new File(originalJobJar.getParentFile(), targetJobJar.getName());
if (originalJobJar.equals(jobJarRenamedAsTarget) == false) {
FileUtils.copyFile(originalJobJar, jobJarRenamedAsTarget);
}
File targetCoprocessorJar = new File(config().getCoprocessorLocalJar());
File coprocessorJarRenamedAsTarget = new File(originalCoprocessorJar.getParentFile(), targetCoprocessorJar.getName());
if (originalCoprocessorJar.equals(coprocessorJarRenamedAsTarget) == false) {
FileUtils.copyFile(originalCoprocessorJar, coprocessorJarRenamedAsTarget);
}
CliCommandExecutor cmdExec = config().getCliCommandExecutor();
cmdExec.copyFile(jobJarRenamedAsTarget.getAbsolutePath(), targetJobJar.getParent());
cmdExec.copyFile(coprocessorJarRenamedAsTarget.getAbsolutePath(), targetCoprocessorJar.getParent());
}
代码示例来源:origin: KylinOLAP/Kylin
public void downloadToLocal() throws IOException {
String localArchive = "../examples/test_case_data/minicluster/hbase-export.tar.gz";
if (kylinConfig.getRunAsRemoteCommand()) {
SSHClient ssh = new SSHClient(kylinConfig.getRemoteHadoopCliHostname(), kylinConfig.getRemoteHadoopCliUsername(), kylinConfig.getRemoteHadoopCliPassword());
try {
ssh.scpFileToLocal(backupArchive, localArchive);
} catch (Exception e) {
e.printStackTrace();
}
} else {
FileUtils.copyFile(new File(backupArchive), new File(localArchive));
}
}
代码示例来源:origin: org.jboss.windup.org.apache.maven.indexer/indexer-core
public void retrieve( String name, File targetFile )
throws IOException, FileNotFoundException
{
FileUtils.copyFile( getFile( name ), targetFile );
}
代码示例来源:origin: de.saumya.mojo/jruby9-common
public void copy(File output, String groupId, String artifactId, String version, String exclusion)
throws MojoExecutionException {
output.mkdirs();
for(Artifact artifact: resolve(groupId, artifactId, version, exclusion)) {
try {
FileUtils.copyFile(artifact.getFile(), new File(output, artifact.getFile().getName()));
} catch (IOException e) {
throw new MojoExecutionException("could not copy: " + artifact, e);
}
}
}
代码示例来源:origin: org.sonatype.security/security-model-xml
@Override
public void backupConfiguration()
throws IOException
{
File file = getConfigurationFile();
File backup = new File( file.getParentFile(), file.getName() + ".bak" );
FileUtils.copyFile( file, backup );
}
代码示例来源:origin: reficio/p2-maven-plugin
private void configureLauncher(String categoryFileLocation, String metadataRepositoryLocation) throws AbstractMojoExecutionException, IOException {
File metadataRepositoryDir = new File(metadataRepositoryLocation).getCanonicalFile();
File categoryDefinitionFileSource = new File(categoryFileLocation);
File categoryDefinitionFileTarget = new File(metadataRepositoryDir, "category.xml");
FileUtils.copyFile(categoryDefinitionFileSource, categoryDefinitionFileTarget);
launcher.setWorkingDirectory(metadataRepositoryDir);
launcher.setApplicationName(CATEGORY_PUBLISHER_APP_NAME);
launcher.addArguments("-categoryDefinition", "file:/" + new File(categoryDefinitionFileTarget.toURI()).getAbsolutePath());
launcher.addArguments("-metadataRepository", "file:/" + new File(metadataRepositoryDir.toURI()).getAbsolutePath());
launcher.addArguments(additionalArgs);
}
代码示例来源:origin: org.codehaus.mojo/rpm-maven-plugin
private void makeSecondCopy() throws MojoFailureException {
try {
this.getLog().info( "Copy " + this.getRPMFile() + " to " + copyTo );
FileUtils.copyFile( this.getRPMFile(), copyTo );
}
catch ( IOException e ) {
throw new MojoFailureException( "Unable to copy file" );
}
}
内容来源于网络,如有侵权,请联系作者删除!