I have a third party library that gives me an Enumeration. I want to work with that enumeration lazily as a Java 8 Stream, calling thing
In Java 9 it is possible to convert an Enumeration to a Stream with a one-liner:
Enumeration en = ... ;
Stream str = StreamSupport.stream(
Spliterators.spliteratorUnknownSize(en.asIterator(), Spliterator.ORDERED),
false
);
(Well, it's a rather long line.)
If you're not on Java 9, you can convert the Enumeration into an Iterator manually using the technique given in Holger's answer.