Java Stream of toStream(Iterable iterable)

Here you can find the source of toStream(Iterable iterable)

Description

Converts an iterable into a stream.

License

Apache License

Parameter

Parameter Description
iterable iterable to convert into a stream

Return

stream

Declaration

public static <T> Stream<T> toStream(Iterable<T> iterable) 

Method Source Code

//package com.java2s;
//License from project: Apache License 

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

public class Main {
    /**//from   w  w  w  . j av  a  2  s  .  c o  m
     * Converts an iterable into a stream.
     * By default the stream cannot be parallelized.
     * @param iterable iterable to convert into a stream
     * @return stream
     */
    public static <T> Stream<T> toStream(Iterable<T> iterable) {
        return StreamSupport.stream(iterable.spliterator(), false);
    }
}

Related

  1. toStream(Collection collection)
  2. toStream(Enumeration e)
  3. toStream(final Iterable iterable)
  4. toStream(final Iterable iterable)
  5. toStream(final T source)
  6. toStream(Iterator iter, boolean parallel)
  7. toStream(Optional value)
  8. toStream(T[] array, boolean parallel)
  9. toStreamLine(final Scanner scanner)