本文整理了Java中org.codehaus.plexus.util.FileUtils.copyStreamToFile()
方法的一些代码示例,展示了FileUtils.copyStreamToFile()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。FileUtils.copyStreamToFile()
方法的具体详情如下:
包路径:org.codehaus.plexus.util.FileUtils
类名称:FileUtils
方法名:copyStreamToFile
[英]Copies bytes from the InputStream 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.
[中]将字节从InputStreamsource
复制到文件destination
。如果目录不存在,则将创建高达destination
的目录。destination
如果已经存在,将被覆盖。
代码示例来源:origin: org.codehaus.plexus/plexus-utils
/**
* Copies bytes from the URL <code>source</code> to a file <code>destination</code>. 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 A <code>URL</code> to copy bytes from.
* @param destination A non-directory <code>File</code> to write bytes to (possibly overwriting).
* @throws IOException if
* <ul>
* <li><code>source</code> URL cannot be opened</li>
* <li><code>destination</code> cannot be written to</li>
* <li>an IO error occurs during copying</li>
* </ul>
*/
public static void copyURLToFile( final URL source, final File destination )
throws IOException
{
copyStreamToFile( new URLInputStreamFacade( source ), destination );
}
代码示例来源:origin: org.codehaus.mojo/nbm-maven-plugin
private void writeFromZip( final ZipFile zip, String zipPath, File destFile, boolean mandatory ) throws MojoExecutionException, IOException
{
final ZipEntry path = zip.getEntry( zipPath );
if (path == null) {
if (mandatory) {
throw new MojoExecutionException( zipPath + " not found in " + zip.getName());
}
getLog().debug(zipPath + " is not present in " + zip.getName());
return;
}
FileUtils.copyStreamToFile( new InputStreamFacade() {
@Override
public InputStream getInputStream() throws IOException
{
return zip.getInputStream( path );
}
}, destFile);
}
代码示例来源:origin: org.apache.maven.indexer/indexer-core
public void addIndexChunk( ResourceFetcher source, String filename )
throws IOException
{
File chunk = new File( dir, filename );
FileUtils.copyStreamToFile( new RawInputStreamFacade( source.retrieve( filename ) ), chunk );
newChunks.add( filename );
}
代码示例来源:origin: mojohaus/nbm-maven-plugin
private void writeFromZip( final ZipFile zip, String zipPath, File destFile, boolean mandatory ) throws MojoExecutionException, IOException
{
final ZipEntry path = zip.getEntry( zipPath );
if (path == null) {
if (mandatory) {
throw new MojoExecutionException( zipPath + " not found in " + zip.getName());
}
getLog().debug(zipPath + " is not present in " + zip.getName());
return;
}
FileUtils.copyStreamToFile( new InputStreamFacade() {
@Override
public InputStream getInputStream() throws IOException
{
return zip.getInputStream( path );
}
}, destFile);
}
代码示例来源:origin: org.jboss.windup.org.apache.maven.indexer/indexer-core
public void addIndexChunk( ResourceFetcher source, String filename )
throws IOException
{
File chunk = new File( dir, filename );
FileUtils.copyStreamToFile( new RawInputStreamFacade( source.retrieve( filename ) ), chunk );
newChunks.add( filename );
}
代码示例来源:origin: org.apache.servicemix.kernel.gshell/org.apache.servicemix.kernel.gshell.core
/**
* Copies bytes from the URL <code>source</code> to a file <code>destination</code>.
* 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 A <code>URL</code> to copy bytes from.
* @param destination A non-directory <code>File</code> to write bytes to (possibly
* overwriting).
* @throws IOException if
* <ul>
* <li><code>source</code> URL cannot be opened</li>
* <li><code>destination</code> cannot be written to</li>
* <li>an IO error occurs during copying</li>
* </ul>
*/
public static void copyURLToFile( final URL source, final File destination )
throws IOException
{
copyStreamToFile( new URLInputStreamFacade( source ) , destination);
}
代码示例来源:origin: org.sonatype.nexus/nexus-indexer
public void addIndexChunk( ResourceFetcher source, String filename )
throws IOException
{
File chunk = new File( dir, filename );
FileUtils.copyStreamToFile( new RawInputStreamFacade( source.retrieve( filename ) ), chunk );
newChunks.add( filename );
}
代码示例来源:origin: apache/maven-indexer
public void addIndexChunk( ResourceFetcher source, String filename )
throws IOException
{
File chunk = new File( dir, filename );
FileUtils.copyStreamToFile( new RawInputStreamFacade( source.retrieve( filename ) ), chunk );
newChunks.add( filename );
}
代码示例来源:origin: eclipse/tycho
@Override
public ArtifactDelta getDelta(InputStream baseline, InputStream reactor, MojoExecution mojo) throws IOException {
File zip = File.createTempFile("zip", ".zip");
try {
FileUtils.copyStreamToFile(new RawInputStreamFacade(baseline), zip);
File zip2 = File.createTempFile("zip2", ".zip");
try {
FileUtils.copyStreamToFile(new RawInputStreamFacade(reactor), zip2);
return zipComparator.getDelta(zip, zip2, mojo);
} finally {
zip2.delete();
}
} finally {
zip.delete();
}
}
代码示例来源:origin: org.apache.servicemix.kernel.gshell/org.apache.servicemix.kernel.gshell.core
copyStreamToFile( new FileInputStreamFacade( source ), destination);
代码示例来源:origin: dtrott/maven-thrift-plugin
truncatePath(classpathJar.getName())), jarEntryName);
uncompressedCopy.getParentFile().mkdirs();
copyStreamToFile(new RawInputStreamFacade(classpathJar
.getInputStream(jarEntry)), uncompressedCopy);
thriftDirectories.add(uncompressedCopy.getParentFile());
代码示例来源:origin: org.codehaus.tycho/maven-osgi-compiler-plugin
private File getNestedJar(BundleDescription bundle, String cp) {
File bundleLocation = new File(bundle.getLocation());
if (bundleLocation.isDirectory()) {
return new File(bundleLocation, cp);
}
File file = new File(storage, bundle.getName() + "_" + bundle.getVersion() + "/" + cp);
try {
ZipFile zip = new ZipFile(bundleLocation);
try {
ZipEntry ze = zip.getEntry(cp);
if (ze != null) {
InputStream is = zip.getInputStream(ze);
FileUtils.copyStreamToFile(new RawInputStreamFacade(is), file);
} else {
// TODO log
}
} finally {
zip.close();
}
} catch (IOException e) {
// XXX log
return null;
}
return file;
}
代码示例来源:origin: org.apache.maven.indexer/indexer-core
public Date setIndexFile( ResourceFetcher source, String filename )
throws IOException
{
cleanCacheDirectory( dir );
result.setFullUpdate( true );
File target = new File( dir, filename );
FileUtils.copyStreamToFile( new RawInputStreamFacade( source.retrieve( filename ) ), target );
return null;
}
代码示例来源:origin: org.jboss.windup.org.apache.maven.indexer/indexer-core
public Date setIndexFile( ResourceFetcher source, String filename )
throws IOException
{
cleanCacheDirectory( dir );
result.setFullUpdate( true );
File target = new File( dir, filename );
FileUtils.copyStreamToFile( new RawInputStreamFacade( source.retrieve( filename ) ), target );
return null;
}
代码示例来源:origin: org.sonatype.nexus/nexus-indexer
public Date setIndexFile( ResourceFetcher source, String filename )
throws IOException
{
cleanCacheDirectory( dir );
result.setFullUpdate( true );
File target = new File( dir, filename );
FileUtils.copyStreamToFile( new RawInputStreamFacade( source.retrieve( filename ) ), target );
return null;
}
代码示例来源:origin: apache/maven-indexer
public Date setIndexFile( ResourceFetcher source, String filename )
throws IOException
{
cleanCacheDirectory( dir );
result.setFullUpdate( true );
File target = new File( dir, filename );
FileUtils.copyStreamToFile( new RawInputStreamFacade( source.retrieve( filename ) ), target );
return null;
}
代码示例来源:origin: org.codehaus.mojo/nbm-maven-plugin
FileUtils.copyStreamToFile( new InputStreamFacade() {
public InputStream getInputStream() throws IOException
FileUtils.copyStreamToFile( new InputStreamFacade() {
public InputStream getInputStream() throws IOException
代码示例来源:origin: mojohaus/nbm-maven-plugin
FileUtils.copyStreamToFile( new InputStreamFacade() {
public InputStream getInputStream() throws IOException
FileUtils.copyStreamToFile( new InputStreamFacade() {
public InputStream getInputStream() throws IOException
代码示例来源:origin: org.sonatype.sisu/sisu-bundle-launcher-jetty
FileUtils.copyStreamToFile(
new InputStreamFacade()
代码示例来源:origin: org.sonatype.nexus/nexus-indexer-lucene-app
private void copyIndexPropertiesToTempDir( Repository repository, File tempDir )
{
InputStream is = null;
try
{
// Need to use RepositoryUID to get around security
ResourceStoreRequest req =
new ResourceStoreRequest( "/.index/" + IndexingContext.INDEX_FILE + ".properties" );
req.setRequestLocalOnly( true );
StorageFileItem item = (StorageFileItem) repository.retrieveItem( true, req );
// Hack to make sure that group properties isn't retrieved from child repo
if ( repository.getId().equals( item.getRepositoryId() ) )
{
is = item.getInputStream();
// FileUtils.copyStreamToFile closes the stream!
FileUtils.copyStreamToFile( new RawInputStreamFacade( is ), new File( tempDir,
IndexingContext.INDEX_FILE + ".properties" ) );
}
}
catch ( Exception e )
{
getLogger().debug( "Unable to copy index properties file, continuing without it", e );
}
}
内容来源于网络,如有侵权,请联系作者删除!