code: public static <E> Stream<E> stream(CloseableIterator<E> iterator, boolean parallel, long size, int characteristics) {
        Stream<E> stream = StreamSupport.stream(Spliterators.spliterator(iterator, size, characteristics), parallel);
        stream.onClose(iterator::close);
        return stream;
     }
docs: Creates a stream that when closed will also close the underlying iterator
  @param iterator iterator to back the stream and subsequently close
  @param parallel whether or not the returned stream is parallel or not
  @param size the size of the iterator if known, otherwise {@link Long#MAX_VALUE} should be passed.
  @param characteristics the characteristics of the iterator to be used
  @param <E> the type of the stream
  @return the stream to use