private static < T > Stream < T > enumerationAsStream ( Enumeration < ? extends T > e ) { Iterator < T > iterator = new Iterator < T > ( ) { @ Override public T next ( ) { return e . nextElement ( ) ; } @ Override public boolean hasNext ( ) { return e . hasMoreElements ( ) ; } } ; return StreamSupport . stream ( Spliterators . spliteratorUnknownSize ( iterator , Spliterator . ORDERED ) , false ) ; }
Returns a new stream that has the same contents as the given enumeration