code: public static <T> Stream<List<T>> aggregate(Stream<T> source, int size) {
          if (size <= 0) throw new IllegalArgumentException("Positive size expected, was: "+size);
          return StreamSupport.stream(new AggregatingSpliterator<>(source.spliterator(), (a, e) -> a.size() < size), false)
                  .onClose(source::close);
      }
docs: Aggregates items from source stream into list of items with fixed size
  @param source - source stream
  @param size - size of the aggregated list
  @param <T> The type over which the stream streams.
  @return Stream of List&lt;T&gt; with all list of size @size with possible exception of last List&lt;T&gt;