public static long copy(final InputStream input, final OutputStream output) throws IOException { byte[] buffer = new byte[DEFAULT_BUFFER_SIZE]; return copy(input, output, buffer); }
@Override public void decompressBlock(byte[] buffer, int offset, int length, OutputStream outputStream) throws IOException { // Decompress the block InputStream blockInputStream = new ByteArrayInputStream(buffer, offset, length); // Build an InputStream corresponding to the compression codec InputStream decompressedBlockInputStream = getBlockDecompressionInputStream(blockInputStream); // Decompress into the specialized result buffer IOStreamUtils.copy(decompressedBlockInputStream, outputStream, copyBuffer); decompressedBlockInputStream.close(); }
@Override public void copyToLocalRoot(String remoteSourceRelativePath, String localDestinationRoot) throws IOException { Path source = new Path(getRemoteAbsolutePath(remoteSourceRelativePath)); File destination = new File(localDestinationRoot + "/" + new Path(remoteSourceRelativePath).getName()); LOG.info("Copying remote file " + source + " to local file " + destination); InputStream inputStream = getInputStream(remoteSourceRelativePath); FileOutputStream fileOutputStream = new FileOutputStream(destination); try { IOStreamUtils.copy(inputStream, fileOutputStream); fileOutputStream.flush(); } finally { inputStream.close(); fileOutputStream.close(); } }
try { LOG.info("Merging remote file " + deltaRemoteFile + " into file " + base.getPath()); long bytesCopied = IOStreamUtils.copy(deltaRemoteInputStream, baseOutputStream); totalOffset += bytesCopied; } finally {