@Override public void flush(final OutputStream outputStream) throws IOException { Args.notNull(outputStream, "Output stream"); flushBuffer(outputStream); outputStream.flush(); }
@Override public void flush(final OutputStream outputStream) throws IOException { Args.notNull(outputStream, "Output stream"); flushBuffer(outputStream); outputStream.flush(); }
@Override public void write(final int b, final OutputStream outputStream) throws IOException { Args.notNull(outputStream, "Output stream"); if (this.fragementSizeHint > 0) { if (this.buffer.isFull()) { flushBuffer(outputStream); } this.buffer.append(b); } else { flushBuffer(outputStream); outputStream.write(b); } }
@Override public void write(final int b, final OutputStream outputStream) throws IOException { Args.notNull(outputStream, "Output stream"); if (this.fragementSizeHint > 0) { if (this.buffer.isFull()) { flushBuffer(outputStream); } this.buffer.append(b); } else { flushBuffer(outputStream); outputStream.write(b); } }
@Override public void write(final byte[] b, final int off, final int len, final OutputStream outputStream) throws IOException { if (b == null) { return; } Args.notNull(outputStream, "Output stream"); // Do not want to buffer large-ish chunks // if the byte array is larger then MIN_CHUNK_LIMIT // write it directly to the output stream if (len > this.fragementSizeHint || len > this.buffer.capacity()) { // flush the buffer flushBuffer(outputStream); // write directly to the out stream outputStream.write(b, off, len); this.metrics.incrementBytesTransferred(len); } else { // Do not let the buffer grow unnecessarily final int freecapacity = this.buffer.capacity() - this.buffer.length(); if (len > freecapacity) { // flush the buffer flushBuffer(outputStream); } // buffer this.buffer.append(b, off, len); } }
@Override public void write(final byte[] b, final int off, final int len, final OutputStream outputStream) throws IOException { if (b == null) { return; } Args.notNull(outputStream, "Output stream"); // Do not want to buffer large-ish chunks // if the byte array is larger then MIN_CHUNK_LIMIT // write it directly to the output stream if (len > this.fragementSizeHint || len > this.buffer.capacity()) { // flush the buffer flushBuffer(outputStream); // write directly to the out stream outputStream.write(b, off, len); this.metrics.incrementBytesTransferred(len); } else { // Do not let the buffer grow unnecessarily final int freecapacity = this.buffer.capacity() - this.buffer.length(); if (len > freecapacity) { // flush the buffer flushBuffer(outputStream); } // buffer this.buffer.append(b, off, len); } }
flushBuffer(outputStream);
flushBuffer(outputStream);