Skip to content

Instantly share code, notes, and snippets.

@benhardy
Last active August 29, 2015 14:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save benhardy/bca790592a553adb5278 to your computer and use it in GitHub Desktop.
Save benhardy/bca790592a553adb5278 to your computer and use it in GitHub Desktop.
java 8 enumeration as stream
public static <T> Stream<T> asStream(final Enumeration<T> horror) {
if (horror.hasMoreElements()) {
return Stream.concat(Stream.of(horror.nextElement()), asStream(horror));
} else {
return Stream.empty();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment