This article, also posted on http://javaalmanac.io, describes gatherers, which provide a general extension point for intermediate operations in Java streams. Gatherers are particularly useful for operations that depend on neighboring elements, all preceding elements, or all elements of a stream.