I want to use streams like:
List<String> result = myArr
.stream()
.filter(line -> !"foo".equals(line))
.collect(Collectors.toList());
but stop the filtering as soon as I have maximum 100 Elements ready to be collected. How can I achieve this without filtering all and calling subList(100, result.size())
?