List of usage examples for org.apache.commons.io IOUtils copyLarge
public static long copyLarge(Reader input, Writer output) throws IOException
Reader
to a Writer
. From source file:org.gradle.api.internal.file.CopyVisitor.java
private void copyFileStreams(File srcFile, File destFile) throws IOException { FileInputStream input = new FileInputStream(srcFile); FileOutputStream output = new FileOutputStream(destFile); try {// w ww . j a va2 s . c o m IOUtils.copyLarge(input, output); } finally { IOUtils.closeQuietly(input); IOUtils.closeQuietly(output); } }
From source file:org.gradle.internal.resource.AbstractExternalResource.java
public void writeTo(OutputStream output) { try {/*w ww. j av a2s. c o m*/ InputStream input = openStream(); try { IOUtils.copyLarge(input, output); } finally { input.close(); } } catch (Exception e) { throw ResourceException.getFailed(getURI(), e); } }
From source file:org.gradle.internal.resource.local.LocalFileStandInExternalResource.java
@Override public ExternalResourceReadResult<Void> writeTo(OutputStream output) { if (!localFile.exists()) { throw ResourceExceptions.getMissing(getURI()); }/*www. ja v a 2s. c om*/ try { CountingInputStream input = new CountingInputStream(new FileInputStream(localFile)); try { IOUtils.copyLarge(input, output); } finally { input.close(); } return ExternalResourceReadResult.of(input.getCount()); } catch (IOException e) { throw ResourceExceptions.getFailed(getURI(), e); } }
From source file:org.gradle.internal.resource.local.LocalFileStandInExternalResource.java
@Override @Nullable/* w w w . ja v a 2 s.c o m*/ public ExternalResourceReadResult<Void> writeToIfPresent(File destination) { if (!localFile.exists()) { return null; } try { CountingInputStream input = new CountingInputStream(new FileInputStream(localFile)); try { FileOutputStream output = new FileOutputStream(destination); try { IOUtils.copyLarge(input, output); } finally { output.close(); } } finally { input.close(); } return ExternalResourceReadResult.of(input.getCount()); } catch (IOException e) { throw ResourceExceptions.getFailed(getURI(), e); } }
From source file:org.gradle.internal.resource.local.LocalFileStandInExternalResource.java
@Override public ExternalResourceWriteResult put(ReadableContent location) { try {//from www . j a v a 2s . co m if (!localFile.canWrite()) { localFile.delete(); } Files.createParentDirs(localFile); InputStream input = location.open(); try { CountingOutputStream output = new CountingOutputStream(new FileOutputStream(localFile)); try { IOUtils.copyLarge(input, output); } finally { output.close(); } return new ExternalResourceWriteResult(output.getCount()); } finally { input.close(); } } catch (IOException e) { throw ResourceExceptions.putFailed(getURI(), e); } }
From source file:org.gradle.internal.resource.transfer.AccessorBackedExternalResource.java
@Nullable @Override//from w w w . j a v a 2 s . c om public ExternalResourceReadResult<Void> writeToIfPresent(File destination) throws ResourceException { try { ExternalResourceReadResponse response = accessor.openResource(name.getUri(), revalidate); if (response == null) { return null; } try { CountingInputStream input = new CountingInputStream(response.openStream()); try { FileOutputStream output = new FileOutputStream(destination); try { IOUtils.copyLarge(input, output); return ExternalResourceReadResult.of(input.getCount()); } finally { output.close(); } } finally { input.close(); } } finally { response.close(); } } catch (IOException e) { throw ResourceExceptions.getFailed(getURI(), e); } }
From source file:org.gradle.internal.resource.transport.file.FileResourceConnector.java
@Override public void put(LocalResource source, URI destination) throws IOException { File target = getFile(destination); if (!target.canWrite()) { target.delete();//from ww w . j ava 2 s .c o m } // if target is writable, the copy will overwrite it without requiring a delete GFileUtils.mkdirs(target.getParentFile()); InputStream input = source.open(); try { FileOutputStream output = new FileOutputStream(target); try { IOUtils.copyLarge(input, output); } finally { output.close(); } } finally { input.close(); } }
From source file:org.gradle.internal.resource.transport.http.RepeatableInputStreamEntity.java
public void writeTo(OutputStream outstream) throws IOException { InputStream content = getContent(); try {//from w w w. j a v a 2 s . c om IOUtils.copyLarge(content, outstream); } finally { IOUtils.closeQuietly(content); } }
From source file:org.gradle.language.cpp.internal.NativeDependencyCache.java
private void unzipTo(File headersZip, File unzipDir) throws IOException { ZipInputStream inputStream = new ZipInputStream(new BufferedInputStream(new FileInputStream(headersZip))); try {/*from w w w. j a va2 s .c o m*/ ZipEntry entry = null; while ((entry = inputStream.getNextEntry()) != null) { if (entry.isDirectory()) { continue; } File outFile = new File(unzipDir, entry.getName()); Files.createParentDirs(outFile); FileOutputStream outputStream = new FileOutputStream(outFile); try { IOUtils.copyLarge(inputStream, outputStream); } finally { outputStream.close(); } } } finally { inputStream.close(); } }
From source file:org.gytheio.content.handler.FileContentReferenceHandlerImpl.java
@Override public long putInputStream(InputStream sourceInputStream, ContentReference targetContentReference) throws ContentIOException { FileOutputStream fileOutputStream = null; try {/*from w w w.ja va 2s .c o m*/ File targetFile = getFile(targetContentReference, false); fileOutputStream = new FileOutputStream(targetFile); long sizeCopied = IOUtils.copyLarge(sourceInputStream, fileOutputStream); fileOutputStream.close(); return sizeCopied; } catch (IOException e) { throw new ContentIOException("Error copying input stream", e); } catch (InterruptedException e) { return 0; } finally { if (fileOutputStream != null) { try { fileOutputStream.close(); sourceInputStream.close(); } catch (IOException e) { } } } }