code: public static ByteBuffer sliceWithOrder(ByteBuffer bytes) {
          ByteBuffer b = bytes.slice();
          return b.order(bytes.order());
      }
docs: Same as ByteBuffer.slice() plus preserving the byte order.