public void write(final byte[] b, int off, int len) throws IOException { if (b == null) { return; } // Do not want to buffer largish chunks // if the byte array is larger then MAX_CHUNK // write it directly to the output stream if (len > MAX_CHUNK || len > this.buffer.capacity()) { // flush the buffer flushBuffer(); // write directly to the out stream this.outstream.write(b, off, len); this.metrics.incrementBytesTransferred(len); } else { // Do not let the buffer grow unnecessarily int freecapacity = this.buffer.capacity() - this.buffer.length(); if (len > freecapacity) { // flush the buffer flushBuffer(); } // buffer this.buffer.append(b, off, len); } }
public void writeLine(final CharArrayBuffer s) throws IOException { if (s == null) { return; } if (this.ascii) { int off = 0; int remaining = s.length(); while (remaining > 0) { int chunk = this.buffer.capacity() - this.buffer.length(); chunk = Math.min(chunk, remaining); if (chunk > 0) { this.buffer.append(s, off, chunk); } if (this.buffer.isFull()) { flushBuffer(); } off += chunk; remaining -= chunk; } } else { // This is VERY memory inefficient, BUT since non-ASCII charsets are // NOT meant to be used anyway, there's no point optimizing it byte[] tmp = s.toString().getBytes(this.charset); write(tmp); } write(CRLF); }
/** * @since 4.1 */ public int capacity() { return this.buffer.capacity(); }
/** * @since 4.1 */ public int capacity() { return this.buffer.capacity(); }
/** * @since 4.1 */ @Override public int capacity() { return this.buffer.capacity(); }
@Override public int capacity() { return this.buffer.capacity(); }
/** * @since 4.1 */ public int capacity() { return this.buffer.capacity(); }
/** * @since 4.1 */ public int capacity() { return this.buffer.capacity(); }
@Override public int capacity() { return this.buffer.capacity(); }
@Override public int capacity() { return this.buffer.capacity(); }
@Override public int capacity() { return this.buffer.capacity(); }
public int capacity() { return this.buffer.capacity(); }
public int capacity() { return this.buffer.capacity(); }
private void clearLineSoFar() { lineSoFar.setLength(0); // Avoid keeping hold of a lot of memory for too long a time: // if we'd constructed a huge buffer, then get rid of it. if (lineSoFar.capacity() > 1024) { lineSoFar = new ByteArrayBuffer(16); } }
public void write(final byte[] b, int off, int len) throws IOException { if (b == null) { return; } // Do not want to buffer largish chunks // if the byte array is larger then MAX_CHUNK // write it directly to the output stream if (len > MAX_CHUNK || len > this.buffer.capacity()) { // flush the buffer flushBuffer(); // write directly to the out stream this.outstream.write(b, off, len); this.metrics.incrementBytesTransferred(len); } else { // Do not let the buffer grow unnecessarily int freecapacity = this.buffer.capacity() - this.buffer.length(); if (len > freecapacity) { // flush the buffer flushBuffer(); } // buffer this.buffer.append(b, off, len); } }
public void write(final byte[] b, final int off, final int len) throws IOException { if (b == null) { return; } // 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.minChunkLimit || len > this.buffer.capacity()) { // flush the buffer flushBuffer(); // write directly to the out stream this.outstream.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(); } // buffer this.buffer.append(b, off, len); } }
public void write(final byte[] b, final int off, final int len) throws IOException { if (b == null) { return; } // 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.minChunkLimit || len > this.buffer.capacity()) { // flush the buffer flushBuffer(); // write directly to the out stream this.outstream.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(); } // buffer this.buffer.append(b, off, len); } }
public void write(final byte[] b, int off, int len) throws IOException { if (b == null) { return; } // Do not want to buffer largish chunks // if the byte array is larger then MAX_CHUNK // write it directly to the output stream if (len > MAX_CHUNK || len > this.buffer.capacity()) { // flush the buffer flushBuffer(); // write directly to the out stream this.outstream.write(b, off, len); this.metrics.incrementBytesTransferred(len); } else { // Do not let the buffer grow unnecessarily int freecapacity = this.buffer.capacity() - this.buffer.length(); if (len > freecapacity) { // flush the buffer flushBuffer(); } // buffer this.buffer.append(b, off, len); } }
@Override public void write(final byte[] b, final int off, final int len) throws IOException { if (b == null) { return; } // 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(); // write directly to the out stream streamWrite(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(); } // buffer this.buffer.append(b, off, len); } }
@Override public void write(final byte[] b, final int off, final int len) throws IOException { if (b == null) { return; } // 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(); // write directly to the out stream streamWrite(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(); } // buffer this.buffer.append(b, off, len); } }