filter stream but collect all code example
Example 1: java stream filter
List<String> result = lines.stream()
.filter(line -> "theLineIWant".equals(line))
.collect(Collectors.toList());
Example 2: java stream and filter
items.stream()
.filter(s->s.contains("B"))
.forEach(System.out::println);