I would like to combine a stream of arrays through a mutable drive.
I am currently doing the following for Stream<Foo[]> :
Foo[] concatenation = streamOfFooArrays.collect(Collector.of( ArrayList<Foo>::new, (acc , els ) -> {acc.addAll(Arrays.asList(els));}, (acc1, acc2) -> {acc1.addAll(acc2); return acc1;}, acc -> acc.toArray(new Foo[x.size()]) ));
However, for something that seems quite useful in general, it disappoints that the standard library does not provide something more immediate.
Am I missing something, or is there a better way?
source share