/** {@inheritDoc} */ public void write(int v) throws IOException { final byte[] buffer = this.buffer; final int position = this.position; if (position == buffer.length) { flush(); buffer[0] = (byte) v; this.position = 1; } else { buffer[position] = (byte) v; this.position = position + 1; } }
/** {@inheritDoc} */ public void write(final byte[] bytes) throws IOException { write(bytes, 0, bytes.length); }
/** * Writes a {@code CHUNK_START} header followed by the size of chunk being flushed followed by the data being flushed. * It will then flush the underlying byte output. * * @throws IOException */ public void flush() throws IOException { final ByteOutput output = this.output; final int pos = this.position; if (pos > 0) { output.write(CHUNK_START); writeInt(pos); final byte[] buffer = this.buffer; output.write(buffer, 0, pos); } this.position = 0; }
/** * Writes a {@code CHUNK_START} header followed by the size of chunk being flushed followed by the data being flushed. * It will then flush the underlying byte output. * * @throws IOException */ public void flush() throws IOException { final ByteOutput output = this.output; final int pos = this.position; if (pos > 0) { output.write(CHUNK_START); writeInt(pos); final byte[] buffer = this.buffer; output.write(buffer, 0, pos); } this.position = 0; }
/** {@inheritDoc} */ public void write(int v) throws IOException { final byte[] buffer = this.buffer; final int position = this.position; if (position == buffer.length) { flush(); buffer[0] = (byte) v; this.position = 1; } else { buffer[position] = (byte) v; this.position = position + 1; } }
/** {@inheritDoc} */ public void write(final byte[] bytes) throws IOException { write(bytes, 0, bytes.length); }
/** * Writes a {@code CHUNK_START} header followed by the size of chunk being flushed followed by the data being flushed. * It will then flush the underlying byte output. * * @throws IOException */ public void flush() throws IOException { final ByteOutput output = this.output; final int pos = this.position; if (pos > 0) { output.write(CHUNK_START); writeInt(pos); final byte[] buffer = this.buffer; output.write(buffer, 0, pos); } this.position = 0; }
/** {@inheritDoc} */ public void write(int v) throws IOException { final byte[] buffer = this.buffer; final int position = this.position; if (position == buffer.length) { flush(); buffer[0] = (byte) v; this.position = 1; } else { buffer[position] = (byte) v; this.position = position + 1; } }
/** {@inheritDoc} */ public void write(final byte[] bytes) throws IOException { write(bytes, 0, bytes.length); }
/** {@inheritDoc} */ public void write(final byte[] bytes, final int off, int len) throws IOException { byte[] buffer = this.buffer; final int position = this.position; int offSet = off; while (offSet < len) { int remaining = buffer.length - position; int toRead = len - offSet; if (toRead < remaining) { System.arraycopy(bytes, offSet, buffer, position, toRead); this.position = position + toRead; offSet = offSet + len; } else { System.arraycopy(bytes, offSet, buffer, position, remaining); this.position += remaining; flush(); offSet = offSet + remaining; } } }
/** {@inheritDoc} */ public void write(final byte[] bytes, final int off, int len) throws IOException { byte[] buffer = this.buffer; final int position = this.position; int offSet = off; while (offSet < len) { int remaining = buffer.length - position; int toRead = len - offSet; if (toRead < remaining) { System.arraycopy(bytes, offSet, buffer, position, toRead); this.position = position + toRead; offSet = offSet + len; } else { System.arraycopy(bytes, offSet, buffer, position, remaining); this.position += remaining; flush(); offSet = offSet + remaining; } } }
/** {@inheritDoc} */ public void write(final byte[] bytes, final int off, int len) throws IOException { byte[] buffer = this.buffer; final int position = this.position; int offSet = off; while (offSet < len) { int remaining = buffer.length - position; int toRead = len - offSet; if (toRead < remaining) { System.arraycopy(bytes, offSet, buffer, position, toRead); this.position = position + toRead; offSet = offSet + len; } else { System.arraycopy(bytes, offSet, buffer, position, remaining); this.position += remaining; flush(); offSet = offSet + remaining; } } }
/** * Flushes the current buffer then write a {@code END} byte. <em>This will not close the underlying byte output</em> * * @throws IOException */ public void close() throws IOException { flush(); output.write(END); // Don't close the underlying output }
/** * Flushes the current buffer then write a {@code END} byte. <em>This will not close the underlying byte output</em> * * @throws IOException */ public void close() throws IOException { flush(); output.write(END); // Don't close the underlying output }
/** * Flushes the current buffer then write a {@code END} byte. <em>This will not close the underlying byte output</em> * * @throws IOException */ public void close() throws IOException { flush(); output.write(END); // Don't close the underlying output }