Java Utililty Methods Stream Operation

List of utility methods to do Stream Operation

Description

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

Method

booleanisEmpty(final Stream stream)
Checks whether the given stream is empty.
return stream.count() <= 0;
booleanisFinite(Stream stream)
is Finite
throw new UnsupportedOperationException("Cannot be implemented");
IterableiterableOf(Stream stream)
convert stream to iterable
return stream::iterator;
StreamiteratorToFiniteStream(Iterator iterator, boolean parallel)
iterator To Finite Stream
final Iterable<T> iterable = () -> iterator;
return StreamSupport.stream(iterable.spliterator(), parallel);
StreamiteratorToStream(final Iterator iterator)
Convert an Iterator to a Stream
return iteratorToStream(iterator, false);
Stream>lazyPartition(final Stream stream, final int maxPartitionSize)
lazy Partition
final Iterator<T> iterator = stream.iterator();
final Iterable<Stream<T>> partitionedIterable = () -> new Iterator<Stream<T>>() {
    public boolean hasNext() {
        return iterator.hasNext();
    public Stream<T> next() {
        List<T> partition = new ArrayList<>();
        while (partition.size() < maxPartitionSize && iterator.hasNext()) {
...
LongStreamlazyStream(PrimitiveIterator.OfLong iterator)
Utility Method to create a stream from an iterator.
return longStream(spliteratorUnknownSize(iterator, IMMUTABLE | NONNULL), false);
long[]longArray(Stream stream)
Returns an array view of a Stream of Long
return stream.mapToLong(Long::valueOf).toArray();
ListlongList(LongStream stream)
Returns a List view of a LongStream
return stream.mapToObj(Long::valueOf).collect(toList());
StreammakeStream(final Object[] array)
make Stream
return Arrays.stream(array).map(Object::toString);