public static boolean equals(ByteBuffer buf1, int o1, int l1, ByteBuffer buf2, int o2, int l2) {
        if ((l1 == 0) || (l2 == 0)) {
            // both 0 length, return true, or else false
            return l1 == l2;
        }
        // Since we're often comparing adjacent sorted data,
        // it's usual to have equal arrays except for the very last byte
        // so check that first
        if (toByte(buf1, o1 + l1 - 1) != toByte(buf2, o2 + l2 - 1)) {
            return false;
        }
        return compareTo(buf1, o1, l1, buf2, o2, l2) == 0;
    }
Copy the given number of bytes from specified offset into a new byte[]

@param buffer input bytebuffer to read
@param offset input offset where Bytes are
@param length the number of bytes to read
@return a new byte[] containing the bytes in the specified range
stroom-bytebuffer/src/main/java/stroom/bytebuffer/hbase/ByteBufferUtils.java