Can we somehow split stream into substreams with no more than N elements in Java? For example
Stream<Integer> s = Stream.of(1,2,3,4,5);
Stream<Stream<Integer>> separated = split(s, 2);
// after that separated should contain stream(1,2), stream(3,4), stream(5)
splitting by two streams solution is correct only for 2 streams, the same for N streams will be very ugly and write-only.