public <C extends Collection<? super T>> C into(C collection) {
        if (isParallel()) {
            @SuppressWarnings("unchecked")
            List<T> list = Arrays.asList((T[]) toArray());
            collection.addAll(list);
        } else {
            Spliterator<T> spltr = spliterator();
            if (collection instanceof ArrayList) {
                long size = spltr.getExactSizeIfKnown();
                if (size >= 0 && size < Integer.MAX_VALUE - collection.size())
                    ((ArrayList<?>) collection).ensureCapacity((int) (collection.size() + size));
            }
            spltr.forEachRemaining(collection::add);
        }
        return collection;
    }
public < C extends Collection < ? super T > > C into ( C collection ) { if ( isParallel ( ) ) { @ SuppressWarnings ( "unchecked" ) List < T > list = Arrays . asList ( ( T [ ] ) toArray ( ) ) ; collection . addAll ( list ) ; } else { Spliterator < T > spltr = spliterator ( ) ; if ( collection instanceof ArrayList ) { long size = spltr . getExactSizeIfKnown ( ) ; if ( size >= 0 && size < Integer . MAX_VALUE - collection . size ( ) ) ( ( ArrayList < ? > ) collection ) . ensureCapacity ( ( int ) ( collection . size ( ) + size ) ) ; } spltr . forEachRemaining ( collection :: add ) ; } return collection ; }
Drains the stream content into the supplied collection.

<p>
This is a <a href="package-summary.html#StreamOps">terminal</a>
operation.

<p>
The stream content is added into the collection using either
{@link Collection#add(Object)} or {@link Collection#addAll(Collection)}
method.

@param <C> type of the resulting collection
@param collection a mutable collection to add new elements into
@return the supplied collection, updated from this stream
@since 0.6.3