public static void moveBufferToStream(OutputStream out, ByteBuffer in, int length)
    throws IOException {
    copyBufferToStream(out, in, in.position(), length);
    skip(in, length);
  }
Copy the data to the output stream and update position in buffer.
@param out    the stream to write bytes to
@param in     the buffer to read bytes from
@param length the number of bytes to copy
hbase-common/src/main/java/org/apache/hadoop/hbase/util/ByteBufferUtils.java