My learning diary

Iterator to Stream

With Google Guava, you can transform an Iterator into a Stream with Streams.stream(...). But that API is only available from Guava 21. If you don’t want to use Guava or if your Guava version is below 21, you need an additional step to convert your Iterator to a Stream:

Stream<String> stream = StreamSupport.stream(
    Spliterators.spliteratorUnknownSize(
        iterator,
        Spliterator.ORDERED
    ),
    false
);

Reference: mkyong.