public void write(int b) { int newcount = mCount + 1; if (newcount > mBuffer.length) mBuffer = Bytes.copyOf(mBuffer, Math.max(mBuffer.length << 1, newcount)); mBuffer[mCount] = (byte) b; mCount = newcount; }
public void write(byte b[], int off, int len) { if ((off < 0) || (off > b.length) || (len < 0) || ((off + len) > b.length) || ((off + len) < 0)) throw new IndexOutOfBoundsException(); if (len == 0) return; int newcount = mCount + len; if (newcount > mBuffer.length) mBuffer = Bytes.copyOf(mBuffer, Math.max(mBuffer.length << 1, newcount)); System.arraycopy(b, off, mBuffer, mCount, len); mCount = newcount; }
public byte[] toByteArray() { return Bytes.copyOf(mBuffer, mCount); }