How to convert an Iterator to a Stream?
One way is to create a Spliterator from the Iterator and use that as a basis for your stream: Iterator<String> sourceIterator = Arrays.asList(“A”, “B”, “C”).iterator(); Stream<String> targetStream = StreamSupport.stream( Spliterators.spliteratorUnknownSize(sourceIterator, Spliterator.ORDERED), false); An alternative which is maybe more readable is to use an Iterable – and creating an Iterable from an Iterator is very easy … Read more