code: public static ByteBuffer slice(ByteBuffer buffer, int start, int length) {
          final int l = buffer.limit();
          final int p = buffer.position();
          buffer.limit(start + length);
          buffer.position(start);
          final ByteBuffer slice = buffer.slice();
          buffer.limit(l);
          buffer.position(p);
          return slice;
      }
docs: Returns a newly allocated {@link ByteBuffer#slice()} of a given {@link ByteBuffer}. The slice and the original buffer will
  share their contents. <br> Upon return from this method, the original buffer's {@link ByteBuffer#position() position} will
  be unchanged, and the returned buffer's position will be 0.
  <p>
  This method is not thread-safe.
  
  @param buffer The buffer to slice.
  @param start The position of the slice's start in the given buffer.
  @param length The length in bytes of the slice.
  @return A slice of the buffer.
  @see ByteBuffer#slice()