@Test public void testWriteAll_Uncompressed() throws IOException { byte[] expectedBytes = new byte[] {1, 2, 3, 4, 5}; stream.pipe(new ByteArrayInputStream(expectedBytes), Mode.COPY); Assert.assertArrayEquals(expectedBytes, outBuffer.toByteArray()); }
public long pipe(InputStream in, Mode mode) throws IOException { long bytesWrittenBefore = out.getNumBytesWritten(); if (mode == Mode.COPY) { int numRead = 0; while ((numRead = in.read(copyBuffer)) >= 0) { out.write(copyBuffer, 0, numRead); } } else { uncompressor.setNowrap(mode == Mode.UNCOMPRESS_NOWRAP); uncompressor.uncompress(in, out); } out.flush(); return out.getNumBytesWritten() - bytesWrittenBefore; }
PartiallyUncompressingPipe implements Closeable { public long pipe(InputStream in, Mode mode) throws IOException { long bytesWrittenBefore = out.getNumBytesWritten(); if (mode == Mode.COPY) { int numRead = 0; while ((numRead = in.read(copyBuffer)) >= 0) { out.write(copyBuffer, 0, numRead); } } else { uncompressor.setNowrap(mode == Mode.UNCOMPRESS_NOWRAP); uncompressor.uncompress(in, out); } out.flush(); return out.getNumBytesWritten() - bytesWrittenBefore; } }
PartiallyUncompressingPipe implements Closeable { public long pipe(InputStream in, Mode mode) throws IOException { long bytesWrittenBefore = out.getNumBytesWritten(); if (mode == Mode.COPY) { int numRead = 0; while ((numRead = in.read(copyBuffer)) >= 0) { out.write(copyBuffer, 0, numRead); } } else { uncompressor.setNowrap(mode == Mode.UNCOMPRESS_NOWRAP); uncompressor.uncompress(in, out); } out.flush(); return out.getNumBytesWritten() - bytesWrittenBefore; } PartiallyUncompressingPipe(OutputStream out, int copyBufferSize); }
PartiallyUncompressingPipe implements Closeable { public long pipe(InputStream in, Mode mode) throws IOException { long bytesWrittenBefore = out.getNumBytesWritten(); if (mode == Mode.COPY) { int numRead = 0; while ((numRead = in.read(copyBuffer)) >= 0) { out.write(copyBuffer, 0, numRead); } } else { uncompressor.setNowrap(mode == Mode.UNCOMPRESS_NOWRAP); uncompressor.uncompress(in, out); } out.flush(); return out.getNumBytesWritten() - bytesWrittenBefore; } PartiallyUncompressingPipe(OutputStream out, int copyBufferSize); long pipe(InputStream in, Mode mode); long getNumBytesWritten(); @Override void close(); }
PartiallyUncompressingPipe implements Closeable { public long pipe(InputStream in, Mode mode) throws IOException { long bytesWrittenBefore = out.getNumBytesWritten(); if (mode == Mode.COPY) { int numRead = 0; while ((numRead = in.read(copyBuffer)) >= 0) { out.write(copyBuffer, 0, numRead); } } else { uncompressor.setNowrap(mode == Mode.UNCOMPRESS_NOWRAP); uncompressor.uncompress(in, out); } out.flush(); return out.getNumBytesWritten() - bytesWrittenBefore; } PartiallyUncompressingPipe(OutputStream out, int copyBufferSize); long pipe(InputStream in, Mode mode); long getNumBytesWritten(); @Override void close();  }