code: public byte[] toByteArray()
      {
          byte[] data = new byte[getSize()];
          int off = 0;
          for (MessageBuffer buffer : list) {
              buffer.getBytes(0, data, off, buffer.size());
              off += buffer.size();
          }
          return data;
      }
docs: Gets a copy of the written data as a byte array.
  <p>
  If your application needs better performance and smaller memory consumption, you may prefer
  {@link #toMessageBuffer()} or {@link #toBufferList()} to avoid copying.
  
  @return the byte array