Is there a Java 8 stream operation that limits a (potentially infinite) Stream until the first element fails to match a predicate?
Stream
In Java 9 we can use
Go to get library AbacusUtil. It provides the exact API you want and more:
IntStream.iterate(1, n -> n + 1).takeWhile(n -> n < 10).forEach(System.out::println);
Declaration: I'm the developer of AbacusUtil.