Java Stream of streamScanner(Scanner scanner)

Here you can find the source of streamScanner(Scanner scanner)

Description

stream Scanner

License

Apache License

Declaration

private static Stream<String> streamScanner(Scanner scanner) 

Method Source Code

//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);
    }
}

Related

  1. streamof(Iterable vals)
  2. streamOf(T value)
  3. streamOfEnumeration(Enumeration e, boolean parallel)
  4. streamOfOptional(Optional element)
  5. streamOrEmpty(Iterable iterable)
  6. streamToList(Stream stream)
  7. toParallelStream(Iterator iter)
  8. toStream(Collection collection)
  9. toStream(Enumeration e)