本文整理了Java中org.codehaus.plexus.util.FileUtils.copyURLToFile()
方法的一些代码示例,展示了FileUtils.copyURLToFile()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。FileUtils.copyURLToFile()
方法的具体详情如下:
包路径:org.codehaus.plexus.util.FileUtils
类名称:FileUtils
方法名:copyURLToFile
[英]Copies bytes from the URL source
to a file destination
. The directories up to destination
will be created if they don't already exist. destination
will be overwritten if it already exists.
[中]将字节从URLsource
复制到文件destination
。如果目录不存在,则将创建高达destination
的目录。destination
如果已经存在,将被覆盖。
代码示例来源:origin: klieber/phantomjs-maven-plugin
@VisibleForTesting
void copyURLToFile(URL url, File file) throws IOException {
FileUtils.copyURLToFile(url, file);
}
}
代码示例来源:origin: torquebox/jruby-maven-plugins
private void copyFile(final File launchDirectory, final String name)
throws IOException {
final File file = new File(launchDirectory, name);
if (!file.exists()) {
FileUtils.copyURLToFile(getClass().getResource("/rails-resources/"
+ name), file);
}
}
代码示例来源:origin: org.apache.maven.plugins/maven-checkstyle-plugin
public void copy( String resourceName ) throws IOException
{
File resource = new File( outputDirectory, resourceName );
if ( ( resource != null ) && ( !resource.exists() ) )
{
URL url =
Thread.currentThread().getContextClassLoader().getResource( resourcePathBase + "/" + resourceName );
FileUtils.copyURLToFile( url, resource );
}
}
代码示例来源:origin: apache/tomcat-maven-plugin
/**
* Copies the specified class resource to the specified file.
*
* @param fromPath the path of the class resource to copy
* @param toFile the file to copy to
* @throws IOException if the file could not be copied
*/
private void copyFile( String fromPath, File toFile )
throws IOException
{
URL fromURL = getClass().getResource( fromPath );
if ( fromURL == null )
{
throw new FileNotFoundException( fromPath );
}
FileUtils.copyURLToFile( fromURL, toFile );
}
代码示例来源:origin: apache/tomcat-maven-plugin
/**
* Copies the specified class resource to the specified file.
*
* @param fromPath the path of the class resource to copy
* @param toFile the file to copy to
* @throws IOException if the file could not be copied
*/
private void copyFile( String fromPath, File toFile )
throws IOException
{
URL fromURL = getClass().getResource( fromPath );
if ( fromURL == null )
{
throw new FileNotFoundException( fromPath );
}
FileUtils.copyURLToFile( fromURL, toFile );
}
代码示例来源:origin: apache/tomcat-maven-plugin
/**
* Copies the specified class resource to the specified file.
*
* @param fromPath the path of the class resource to copy
* @param toFile the file to copy to
* @throws IOException if the file could not be copied
*/
private void copyFile( String fromPath, File toFile )
throws IOException
{
URL fromURL = getClass().getResource( fromPath );
if ( fromURL == null )
{
throw new FileNotFoundException( fromPath );
}
FileUtils.copyURLToFile( fromURL, toFile );
}
代码示例来源:origin: org.sonatype.buup/buup-editor
/**
* Replaces the wrapper.conf file with the provided one. Nice to have if configuration file comes from classpath.
*
* @param url
* @throws IOException
*/
public void swapInWrapperConf( URL url )
throws IOException
{
FileUtils.copyURLToFile( url, getWrapperConfFile() );
}
代码示例来源:origin: net.flexmojos.oss/flexmojos-maven-plugin
private void copyEmbedTemplate( String path )
throws MojoExecutionException
{
URL url = getClass().getResource( "/templates/wrapper/" + path + ".zip" );
File template = new File( templateOutputDirectory, "template.zip" );
try
{
FileUtils.copyURLToFile( url, template );
}
catch ( IOException e )
{
throw new MojoExecutionException( "Unable to copy template to: " + template, e );
}
extractZipTemplate( templateOutputDirectory, template );
}
代码示例来源:origin: org.codehaus.mojo/cobertura-maven-plugin
private String getLog4jConfigFile()
{
String resourceName = "cobertura-plugin/log4j-info.properties";
if ( getLog().isDebugEnabled() )
{
resourceName = "cobertura-plugin/log4j-debug.properties";
}
if ( quiet )
{
resourceName = "cobertura-plugin/log4j-error.properties";
}
String path = null;
try
{
File log4jconfigFile = File.createTempFile( "log4j", "config.properties" );
URL log4jurl = this.getClass().getClassLoader().getResource( resourceName );
FileUtils.copyURLToFile( log4jurl, log4jconfigFile );
log4jconfigFile.deleteOnExit();
path = log4jconfigFile.toURL().toExternalForm();
}
catch ( MalformedURLException e )
{
// ignore
}
catch ( IOException e )
{
// ignore
}
return path;
}
代码示例来源:origin: org.apache.maven.plugins/maven-jxr-plugin
/**
* Copy styles and related resources to the given directory
*
* @param dir the directory to copy the resources to
* @param sourceFolder resources subfolder to copy from
* @param files names of files to copy
*/
private void copyResources( String dir, String sourceFolder, String... files )
{
try
{
for ( String file : files )
{
URL resourceUrl = this.getClass().getClassLoader().getResource( sourceFolder + file );
File destResourceFile = new File( dir, file );
FileUtils.copyURLToFile( resourceUrl, destResourceFile );
}
}
catch ( IOException e )
{
getLog().warn( "An error occured while copying the resource to the target directory", e );
}
}
代码示例来源:origin: net.flexmojos.oss/flexmojos-maven-plugin
FileUtils.copyURLToFile( url, fontsSer );
代码示例来源:origin: fusesource/hawtjni
private void copyTemplateResource(String file, String output, boolean filter) throws MojoExecutionException {
try {
File target = FileUtils.resolveFile(packageDirectory, output);
if( target.isFile() && target.canRead() ) {
return;
}
URL source = getClass().getClassLoader().getResource("project-template/" + file);
File tmp = FileUtils.createTempFile("tmp", "txt", new File(project.getBuild().getDirectory()));
try {
FileUtils.copyURLToFile(source, tmp);
FileUtils.copyFile(tmp, target, encoding, filters(filter), true);
} finally {
tmp.delete();
}
} catch (IOException e) {
throw new MojoExecutionException("Could not extract template resource: "+file, e);
}
}
代码示例来源:origin: net.flexmojos.oss/flexmojos-maven-plugin
FileUtils.copyURLToFile( url, fontsSer );
代码示例来源:origin: net.flexmojos.oss/flexmojos-maven-plugin
public String[] getLocalesRuntime()
{
if ( localesRuntime == null )
{
return null;
}
try
{
File rbBeacon = new File( getTargetDirectory(), getFinalName() + "." + RB_SWC );
FileUtils.copyURLToFile( getClass().getResource( "/rb.swc" ), rbBeacon );
getLog().info( "Installing resource bundle beacon: " + rbBeacon );
projectHelper.attachArtifact( project, RB_SWC, rbBeacon );
}
catch ( IOException e )
{
throw new MavenRuntimeException( "Failed to create beacon resource bundle", e );
}
return localesRuntime;
}
代码示例来源:origin: org.codehaus.mojo/nbm-maven-plugin
FileUtils.copyURLToFile( new URL( url ), f );
found = true;
代码示例来源:origin: jenkinsci/acceptance-test-harness
private void copyAutoterminateScript(String host) throws IOException, InterruptedException {
//run terminate script
URL script =
this.getClass().getClassLoader().getResource("org/jenkinsci/test/acceptance/machine/autoterminate.sh");
File tempScriptFile = File.createTempFile("autoterminate", ".sh");
try {
FileUtils.copyURLToFile(script, tempScriptFile);
logger.info(String.format(
"Executing auto-terminate script on remote machine: %s, it will terminate after 180 minutes of "
+ "inactivity.",
host));
try (Ssh ssh = new Ssh(host)) {
authenticator().authenticate(ssh.getConnection());
ssh.copyTo(tempScriptFile.getAbsolutePath(), "autoterminate.sh", ".");
ssh.executeRemoteCommand("chmod +x ./autoterminate.sh ; touch nohup.out");
//wait for 3 hours before termination
ssh.getConnection().exec(String
.format("nohup ./autoterminate.sh %s %s `</dev/null` >nohup.out 2>&1 &", config.getUser(),
AUTO_TERMINATE_TIMEOUT), System.out);
}
} finally {
if (!tempScriptFile.delete()) {
tempScriptFile.deleteOnExit();
}
}
}
代码示例来源:origin: mojohaus/nbm-maven-plugin
FileUtils.copyURLToFile( new URL( url ), f );
found = true;
代码示例来源:origin: org.apache.maven.plugins/maven-jxr-plugin
FileUtils.copyURLToFile( stylesheetUrl, destStylesheetFile );
内容来源于网络,如有侵权,请联系作者删除!