public static void copyFromBufferToBuffer(ByteBuffer in, ByteBuffer out, int sourceOffset,
    int destinationOffset, int length) {
    if (in.hasArray() && out.hasArray()) {
      System.arraycopy(in.array(), sourceOffset + in.arrayOffset(), out.array(),
        out.arrayOffset() + destinationOffset, length);
    } else if (UNSAFE_AVAIL) {
      UnsafeAccess.copy(in, sourceOffset, out, destinationOffset, length);
    } else {
      ByteBuffer outDup = out.duplicate();
      outDup.position(destinationOffset);
      ByteBuffer inDup = in.duplicate();
      inDup.position(sourceOffset).limit(sourceOffset + length);
      outDup.put(inDup);
    }
    // We used to return a result but disabled; return destinationOffset + length;
  }
Copy from one buffer to another from given offset. This will be absolute positional copying and
won't affect the position of any of the buffers.
@param in                input bytebuffer
@param out               destination bytebuffer
@param sourceOffset      offset of source buffer
@param destinationOffset offset of destination buffer
@param length            the number of bytes to copy
hbase-common/src/main/java/org/apache/hadoop/hbase/util/ByteBufferUtils.java