@Override public void close() throws IOException { try (Closeable ignored = outputStream) { flushBufferToOutputStream(); } }
@Override public void close() throws IOException { try (Closeable ignored = outputStream) { flushBufferToOutputStream(); } }
@Override public void flush() throws IOException { flushBufferToOutputStream(); outputStream.flush(); }
@Override public void flush() throws IOException { flushBufferToOutputStream(); outputStream.flush(); }
private void ensureWritableBytes(int minWritableBytes) { if (bufferPosition + minWritableBytes > slice.length()) { flushBufferToOutputStream(); } }
private void ensureWritableBytes(int minWritableBytes) { if (bufferPosition + minWritableBytes > slice.length()) { flushBufferToOutputStream(); } }
@Override public void writeBytes(byte[] source, int sourceIndex, int length) { // Write huge chunks direct to OutputStream if (length >= MINIMUM_CHUNK_SIZE) { flushBufferToOutputStream(); writeToOutputStream(source, sourceIndex, length); bufferOffset += length; } else { ensureWritableBytes(length); slice.setBytes(bufferPosition, source, sourceIndex, length); bufferPosition += length; } }
@Override public void writeBytes(Slice source, int sourceIndex, int length) { // Write huge chunks direct to OutputStream if (length >= MINIMUM_CHUNK_SIZE) { flushBufferToOutputStream(); writeToOutputStream(source, sourceIndex, length); bufferOffset += length; } else { ensureWritableBytes(length); slice.setBytes(bufferPosition, source, sourceIndex, length); bufferPosition += length; } }
@Override public void writeBytes(byte[] source, int sourceIndex, int length) { // Write huge chunks direct to OutputStream if (length >= MINIMUM_CHUNK_SIZE) { flushBufferToOutputStream(); writeToOutputStream(source, sourceIndex, length); bufferOffset += length; } else { ensureWritableBytes(length); slice.setBytes(bufferPosition, source, sourceIndex, length); bufferPosition += length; } }
@Override public void writeBytes(Slice source, int sourceIndex, int length) { // Write huge chunks direct to OutputStream if (length >= MINIMUM_CHUNK_SIZE) { flushBufferToOutputStream(); writeToOutputStream(source, sourceIndex, length); bufferOffset += length; } else { ensureWritableBytes(length); slice.setBytes(bufferPosition, source, sourceIndex, length); bufferPosition += length; } }