code: public void write(byte[] buffer, int offset, int count) throws IOException {
      if (offset < 0 || count < 0 || offset + count > buffer.length) {
        throw new ArrayIndexOutOfBoundsException("length=" + buffer.length + "; regionStart=" + offset
            + "; regionLength=" + count);
      }
      ensureValid();
      realloc(mCount + count);
      mBufRef.get().write(mCount, buffer, offset, count);
      mCount += count;
    }
docs: Writes {@code count} bytes from the byte array {@code buffer} starting at
  position {@code offset} to this stream.
  The underlying stream MUST be valid
  
  @param buffer the source buffer to read from
  @param offset the start position in {@code buffer} from where to get bytes.
  @param count the number of bytes from {@code buffer} to write to this stream.
  @throws IOException if an error occurs while writing to this stream.
  @throws IndexOutOfBoundsException
  if {@code offset < 0} or {@code count < 0}, or if
  {@code offset + count} is bigger than the length of
  {@code buffer}.
  @throws InvalidStreamException if the stream is invalid