Is it possible to create a Stream from an Iterator, in which the sequence of objects is the same as that generated by calling the iterator\'s next() method repeatedly? The s
static Stream iteratorToFiniteStream(final Iterator iterator) { return StreamSupport.stream(Spliterators.spliteratorUnknownSize(iterator, 0), false); } static Stream iteratorToInfiniteStream(final Iterator iterator) { return Stream.generate(iterator::next); }