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
According to Guava docs, you could use the Iterators.forEnumeration()
method:
Enumeration enumeration = ...;
Iterator iterator = Iterators.forEnumeration(enumeration);
And in this question, it is explained how to get a stream from an iterator:
Stream stream = StreamSupport.stream(
Spliterators.spliteratorUnknownSize(
iterator, Spliterator.ORDERED),
false);