public static < E > Stream < E > stream ( CloseableSpliterator < E > spliterator , boolean parallel ) { Stream < E > stream = StreamSupport . stream ( spliterator , parallel ) ; stream . onClose ( spliterator :: close ) ; return stream ; }
Creates a stream that when closed will also close the underlying spliterator