@Override
  public void write(byte[] b, int off, int len) throws IOException {
    int toWrite = 0;
    while (len > 0) {
      toWrite = Math.min(len, this.curBuf.remaining());
      ByteBufferUtils.copyFromArrayToBuffer(this.curBuf, b, off, toWrite);
      off += toWrite;
      len -= toWrite;
      if (len > 0) {
        allocateNewBuffer();// The curBuf is over. Let us move to the next one
      }
    }
  }
We can be assured that the buffers returned by this method are all flipped
@return list of bytebuffers
hbase-common/src/main/java/org/apache/hadoop/hbase/io/ByteBufferListOutputStream.java