# A Zipping Gatherer

DevFeed: [A Zipping Gatherer](<https://devfeed.tech/articles/a-zipping-gatherer-18894.md>)

Original publisher: [Read original article](<https://www.morling.dev/blog/zipping-gatherer/>)

Published: 2024-03-18T17:12:00Z

Content type: tutorial

Language: en

Sources: [Gunnar Morling](<https://devfeed.tech/sources/gunnar-morling.md>)

Topics: [Java](<https://devfeed.tech/topics/java.md>), [Streams](<https://devfeed.tech/topics/streams.md>), [Code](<https://devfeed.tech/topics/code.md>)

Tags: [code](<https://devfeed.tech/tags/code.md>), [implementation](<https://devfeed.tech/tags/implementation.md>), [java](<https://devfeed.tech/tags/java.md>), [preview](<https://devfeed.tech/tags/preview.md>), [streams](<https://devfeed.tech/tags/streams.md>)

## AI overview

This tutorial explains how to implement a zip-like operation for Java Streams using the preview Stream Gatherer API introduced in Java 22. The implementation combines corresponding elements from two streams and stops when either stream is exhausted.

## Source excerpt

The other day, I was looking for means of zipping two Java streams: connecting them element by element--essentially a join based on stream offset position--and emitting an output stream with the results. Unfortunately, there is no zip() method offered by the Java Streams API itself. While it was considered for inclusion in early preview versions, the method was removed before the API went GA with Java 8 and you have to resort to 3rd party libraries such as Google Guava if you need this functionality.