/** * @see java.io.OutputStream#write(byte[], int, int) */ @Override public void write(byte[] b, int off, int len) { buffer.append(b, off, len); }
/** * Appends single <code>byte</code> to buffer. */ public FastByteBuffer append(byte element) { if ((currentBuffer == null) || (offset == currentBuffer.length)) { needNewBuffer(size + 1); } currentBuffer[offset] = element; offset++; size++; return this; }
/** * Creates a new byte array output stream, with a buffer capacity of * the specified size, in bytes. * * @param size the initial size. * @throws IllegalArgumentException if size is negative. */ public FastByteArrayOutputStream(int size) { buffer = new FastByteBuffer(size); }
/** * @see java.io.ByteArrayOutputStream#toByteArray() */ public byte[] toByteArray() { return buffer.toArray(); }
/** * @see java.io.ByteArrayOutputStream#size() */ public int size() { return buffer.size(); }
/** * @see java.io.ByteArrayOutputStream#reset() */ public void reset() { buffer.clear(); }
/** * Appends <code>byte</code> array to buffer. */ public FastByteBuffer append(byte[] array) { return append(array, 0, array.length); }
needNewBuffer(newSize);
/** * Writes single byte. */ @Override public void write(int b) { buffer.append((byte) b); }
/** * Appends single <code>byte</code> to buffer. */ public FastByteBuffer append(byte element) { if ((currentBuffer == null) || (offset == currentBuffer.length)) { needNewBuffer(size + 1); } currentBuffer[offset] = element; offset++; size++; return this; }
/** * Appends <code>byte</code> array to buffer. */ public FastByteBuffer append(byte[] array) { return append(array, 0, array.length); }