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 my StreamEx library there's simple method StreamEx.of(Enumeration) which does the job:
Stream stream = StreamEx.of(enumeration);
Note that it not just a shortcut to the @Holger solution, but implemented in different manner. In particular, it has significantly better parallel execution characteristics compared to solutions involving Spliterators.spliteratorUnknownSize()
.