(String[] args)
| 7 | |
| 8 | public class SpecialCollector { |
| 9 | public static void |
| 10 | main(String[] args) throws Exception { |
| 11 | ArrayList<String> words = |
| 12 | FileToWords.stream("Cheese.dat") |
| 13 | .collect(ArrayList::new, |
| 14 | ArrayList::add, |
| 15 | ArrayList::addAll); |
| 16 | words.stream() |
| 17 | .filter(s -> s.equals("cheese")) |
| 18 | .forEach(System.out::println); |
| 19 | } |
| 20 | } |
| 21 | /* Output: |
| 22 | cheese |