code: @Override
      public void write(byte[] buffer, int offset, int len)
      {
          // avoid int overflow
          if (offset < 0 || offset > buffer.length || len < 0 || len > buffer.length - offset)
              throw new IndexOutOfBoundsException();
  
          if (len == 0)
              return;
  
          /* Expand if necessary */
          expand(len);
  
          for (int i = count, j = offset; j < offset + len; i++, j++)
              buf.put(i, buffer[j]);
  
          count += len;
      }
docs: Writes {@code count} bytes from the byte buffer {@code buffer} starting at
  offset {@code index} to this stream.
  
  @param buffer
  the buffer to be written.
  @param offset
  the initial position in {@code buffer} to retrieve bytes.
  @param len
  the number of bytes of {@code buffer} to write.
  @throws NullPointerException
  if {@code buffer} is {@code null}.
  @throws IndexOutOfBoundsException
  if {@code offset < 0} or {@code len < 0}, or if
  {@code offset + len} is greater than the length of
  {@code buffer}.