Here you can find the source of streamScanner(Scanner scanner)
private static Stream<String> streamScanner(Scanner scanner)
//package com.java2s; //License from project: Apache License import java.util.Scanner; import java.util.Spliterator; import java.util.Spliterators; import java.util.stream.Stream; import java.util.stream.StreamSupport; public class Main { private static Stream<String> streamScanner(Scanner scanner) { return StreamSupport .stream(Spliterators.spliteratorUnknownSize(scanner, Spliterator.ORDERED | Spliterator.NONNULL), false)/*w w w .ja v a 2 s. c om*/ .onClose(scanner::close); } }