In JDK 8 with lambda b93 there was a class java.util.stream.Streams.zip in b93 which could be used to zip streams (this is illustrated in the tutorial Exploring Java8 Lambda
I humbly suggest this implementation. The resulting stream is truncated to the shorter of the two input streams.
public static Stream zip(Stream leftStream, Stream rightStream, BiFunction combiner) {
Spliterator lefts = leftStream.spliterator();
Spliterator rights = rightStream.spliterator();
return StreamSupport.stream(new AbstractSpliterator(Long.min(lefts.estimateSize(), rights.estimateSize()), lefts.characteristics() & rights.characteristics()) {
@Override
public boolean tryAdvance(Consumer super T> action) {
return lefts.tryAdvance(left->rights.tryAdvance(right->action.accept(combiner.apply(left, right))));
}
}, leftStream.isParallel() || rightStream.isParallel());
}