Java Stream Operation enumerationAsStream(Enumeration e)

Here you can find the source of enumerationAsStream(Enumeration e)

Description

enumeration As Stream

License

Open Source License

Declaration

public static <T> Stream<T> enumerationAsStream(Enumeration<T> e) 

Method Source Code


//package com.java2s;
//License from project: Open Source License 

import java.util.Enumeration;
import java.util.Iterator;
import java.util.Spliterator;
import java.util.Spliterators;
import java.util.stream.Stream;
import java.util.stream.StreamSupport;

public class Main {
    public static <T> Stream<T> enumerationAsStream(Enumeration<T> e) {
        return StreamSupport.stream(Spliterators.spliteratorUnknownSize(new Iterator<T>() {
            public T next() {
                return e.nextElement();
            }/*from  www.java  2s  .com*/

            public boolean hasNext() {
                return e.hasMoreElements();
            }
        }, Spliterator.ORDERED), false);
    }
}

Related

  1. concat(IntStream... streams)
  2. concat(Stream... streams)
  3. containsOnly(Stream stream, long size)
  4. createStream(final Iterator iterator)
  5. endsWith(Stream stream, Iterable iterable)
  6. equals(Stream first, Stream second)
  7. factorStream(long number)
  8. filterInstances(Stream stream, Class clazz)
  9. filterType(Stream stream, Class type)