Java Stream of stream(Iterable input)

Here you can find the source of stream(Iterable input)

Description

stream

License

Open Source License

Declaration

public static <S> Stream<S> stream(Iterable<S> input) 

Method Source Code


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

import java.util.Iterator;
import java.util.stream.Stream;
import java.util.stream.StreamSupport;

public class Main {
    public static <S> Stream<S> stream(Iterator<S> input) {
        return stream(input, false);
    }/*w  w w  . j  a  v  a2 s  .  c  o  m*/

    private static <S> Stream<S> stream(Iterator<S> input, boolean parallel) {
        Iterable<S> it = () -> input;
        return StreamSupport.stream(it.spliterator(), parallel);
    }

    public static <S> Stream<S> stream(Iterable<S> input) {
        return stream(input, false);
    }

    private static <S> Stream<S> stream(Iterable<S> input, boolean parallel) {
        return StreamSupport.stream(input.spliterator(), parallel);
    }
}

Related

  1. stream(Class clazz)
  2. stream(Collection collection)
  3. stream(Enumeration enumeration)
  4. stream(final Iterator iterator)
  5. stream(Iterable iterable)
  6. stream(Iterable iterable)
  7. stream(Iterable iterable)
  8. stream(Iterable it)
  9. stream(Iterator iterator)