Here you can find the source of stream(Iterator
public static <T> Stream<T> stream(Iterator<T> iterator)
//package com.java2s; //License from project: Apache License 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 final static int DEFAULT_ITERATOR_SPLITERATOR_FLAGS = (Spliterator.CONCURRENT | Spliterator.ORDERED); public static <T> Stream<T> stream(Iterator<T> iterator) { return stream(iterator, -1); }//from ww w.j ava 2 s . c o m public static <T> Stream<T> stream(Iterator<T> iterator, long size) { return StreamSupport.stream( ((size >= 0) ? Spliterators.spliterator(iterator, size, (DEFAULT_ITERATOR_SPLITERATOR_FLAGS | Spliterator.SIZED)) : Spliterators.spliteratorUnknownSize(iterator, DEFAULT_ITERATOR_SPLITERATOR_FLAGS)), false); } }