public byte[] toByteArray() {
    return Arrays.copyOf(buf, pos);
  }
Copies the content of this Stream into a new byte array.
@return the contents of this output stream, as new byte array.
hbase-common/src/main/java/org/apache/hadoop/hbase/io/ByteArrayOutputStream.java