Java tutorial
//package com.java2s; import java.util.*; import java.util.stream.Stream; import java.util.stream.StreamSupport; public class Main { /** * Creates a parallel {@code Stream} using a given {@code Iterator} * as the source of elements, with no initial size estimate. * * @return a parallel {@code Stream} over the remaining items in the iterator * @see Spliterators#spliteratorUnknownSize(Iterator, int) */ public static <T> Stream<T> parallelStream(Iterator<T> iterator) { return StreamSupport.stream(Spliterators.spliteratorUnknownSize(iterator, 0), true); } /** * Creates a sequential {@code Stream} using a given {@code Iterator} * as the source of elements, with no initial size estimate. * * @return a sequential {@code Stream} over the remaining items in the iterator * @see Spliterators#spliteratorUnknownSize(Iterator, int) */ public static <T> Stream<T> stream(Iterator<T> iterator) { return StreamSupport.stream(Spliterators.spliteratorUnknownSize(iterator, 0), false); } }