public static < T > Stream < T > takeWhile ( Stream < T > source , Predicate < T > condition ) { return StreamSupport . stream ( TakeWhileSpliterator . over ( source . spliterator ( ) , condition ) , false ) . onClose ( source :: close ) ; }
Construct a stream which takes values from the source stream for as long as they meet the supplied condition and stops as soon as a value is encountered which does not meet the condition .