Java Utililty Methods Stream of

List of utility methods to do Stream of

Description

The list of methods to do Stream of are organized into topic(s).

Method

StreamstreamOrEmpty(Iterable iterable)
stream Or Empty
return iterable != null ? StreamSupport.stream(iterable.spliterator(), false) : Stream.empty();
StreamstreamScanner(Scanner scanner)
stream Scanner
return StreamSupport
        .stream(Spliterators.spliteratorUnknownSize(scanner, Spliterator.ORDERED | Spliterator.NONNULL),
                false)
        .onClose(scanner::close);
ArrayListstreamToList(Stream stream)
stream To List
return (ArrayList<T>) stream.collect(Collectors.toList());
StreamtoParallelStream(Iterator iter)
to Parallel Stream
Spliterator<T> spliter = Spliterators.spliteratorUnknownSize(iter, Spliterator.NONNULL);
return StreamSupport.stream(spliter, true);
StreamtoStream(Collection collection)
to Stream
if (collection == null) {
    return Stream.empty();
} else {
    return collection.stream();
StreamtoStream(Enumeration e)
Transform an Enumeration to a Stream
return StreamSupport.stream(Spliterators.spliteratorUnknownSize(new Iterator<T>() {
    public T next() {
        return e.nextElement();
    public boolean hasNext() {
        return e.hasMoreElements();
}, Spliterator.ORDERED), false);
...
StreamtoStream(final Iterable iterable)
to Stream
return toList(iterable).stream();
StreamtoStream(final Iterable iterable)
to Stream
return toStream(iterable.iterator());
StreamtoStream(final T source)
to Stream
return Stream.of(source);
StreamtoStream(Iterable iterable)
Converts an iterable into a stream.
return StreamSupport.stream(iterable.spliterator(), false);