protected void flushBuffer() throws IOException { int len = this.buffer.length(); if (len > 0) { this.outstream.write(this.buffer.buffer(), 0, len); this.buffer.clear(); this.metrics.incrementBytesTransferred(len); } }
private int lineFromLineBuffer(final CharArrayBuffer charbuffer) throws IOException { // discard LF if found int l = this.linebuffer.length(); if (l > 0) { if (this.linebuffer.byteAt(l - 1) == HTTP.LF) { l--; this.linebuffer.setLength(l); } // discard CR if found if (l > 0) { if (this.linebuffer.byteAt(l - 1) == HTTP.CR) { l--; this.linebuffer.setLength(l); } } } l = this.linebuffer.length(); if (this.ascii) { charbuffer.append(this.linebuffer, 0, l); } else { // This is VERY memory inefficient, BUT since non-ASCII charsets are // NOT meant to be used anyway, there's no point optimizing it String s = new String(this.linebuffer.buffer(), 0, l, this.charset); charbuffer.append(s); } return l; }
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); }
if (this.maxLineLen > 0 && this.linebuffer.length() >= this.maxLineLen) { throw new IOException("Maximum line length limit exceeded");
/** * @since 4.1 */ public int length() { return this.buffer.length(); }
/** * @since 4.1 */ @Override public int length() { return this.buffer.length(); }
public void onChar(int c) { if (c=='\n' || c=='\r') { if (lineSoFar.length() > 0) { //suppress blank lines, so that we can treat either newline char as a line separator //(eg to show curl updates frequently) onLine(lineSoFar.buffer(), lineSoFar.length()); clearLineSoFar(); } } else { lineSoFar.append(c); } }
@Override public void close() throws IOException { try { onLine(lineSoFar.buffer(), lineSoFar.length()); clearLineSoFar(); } finally { out.close(); running.set(false); } }
protected void flushBuffer() throws IOException { int len = this.buffer.length(); if (len > 0) { this.outstream.write(this.buffer.buffer(), 0, len); this.buffer.clear(); this.metrics.incrementBytesTransferred(len); } }
protected void flushBuffer() throws IOException { final int len = this.buffer.length(); if (len > 0) { this.outstream.write(this.buffer.buffer(), 0, len); this.buffer.clear(); this.metrics.incrementBytesTransferred(len); } }
protected void flushBuffer() throws IOException { final int len = this.buffer.length(); if (len > 0) { this.outstream.write(this.buffer.buffer(), 0, len); this.buffer.clear(); this.metrics.incrementBytesTransferred(len); } }
protected void flushBuffer() throws IOException { final int len = this.buffer.length(); if (len > 0) { this.outstream.write(this.buffer.buffer(), 0, len); this.buffer.clear(); this.metrics.incrementBytesTransferred(len); } }
protected void flushBuffer() throws IOException { int len = this.buffer.length(); if (len > 0) { this.outstream.write(this.buffer.buffer(), 0, len); this.buffer.clear(); this.metrics.incrementBytesTransferred(len); } }
URL url = new URL(imgBaseUrl + ss.getString("foto")); URLConnection connection = url.openConnection(); FlushedInputStream fis = new FlushedInputStream(connection.getInputStream()); ByteArrayBuffer baf = new ByteArrayBuffer(100); int current = 0; while((current = fis.read()) != -1){ baf.append((byte)current); } fis.close(); holder.resim.setImageBitmap(BitmapFactory.decodeByteArray(baf, 0, baf.length()));
private void flushBuffer() throws IOException { final int len = this.buffer.length(); if (len > 0) { streamWrite(this.buffer.buffer(), 0, len); this.buffer.clear(); this.metrics.incrementBytesTransferred(len); } }
private void flushBuffer() throws IOException { final int len = this.buffer.length(); if (len > 0) { streamWrite(this.buffer.buffer(), 0, len); this.buffer.clear(); this.metrics.incrementBytesTransferred(len); } }
private void flushBuffer() throws IOException { final int len = this.buffer.length(); if (len > 0) { streamWrite(this.buffer.buffer(), 0, len); this.buffer.clear(); this.metrics.incrementBytesTransferred(len); } }