Reputation: 4902
How can I convert Stream<int[]>
into int[]
without using forEach
?
final Stream<int[]> stream = foos.stream()
.map(foos -> insertQuery(contact, create))
.map(create::batch)
.map(Batch::execute); //Batch::execute will return the int[]
Upvotes: 6
Views: 701
Reputation: 28183
Use flatMapToInt
int[] result = stream.flatMapToInt(Arrays::stream).toArray();
Upvotes: 8