@@ -0,0 +1,2498 @@
+package com.winterbe.java8;%0A%0Aimport java.io.IOException;%0Aimport java.math.BigDecimal;%0Aimport java.nio.file.Files;%0Aimport java.nio.file.Path;%0Aimport java.nio.file.Paths;%0Aimport java.util.Arrays;%0Aimport java.util.stream.IntStream;%0Aimport java.util.stream.Stream;%0A%0A/**%0A * @author Benjamin Winterberg%0A */%0Apublic class Streams6 %7B%0A%0A    public static void main(String%5B%5D args) throws IOException %7B%0A//        test1();%0A//        test2();%0A//        test3();%0A//        test4();%0A//        test5();%0A//        test6();%0A//        test7();%0A        test8();%0A    %7D%0A%0A    private static void test8() throws IOException %7B%0A        Path start = Paths.get(%22/Users/benny/Documents%22);%0A        int maxDepth = 5;%0A        long fileCount =%0A            Files%0A                .walk(start, maxDepth)%0A                .filter(path -%3E String.valueOf(path).endsWith(%22xls%22))%0A                .count();%0A        System.out.format(%22XLS files found: %25s%22, fileCount);%0A    %7D%0A%0A    private static void test7() throws IOException %7B%0A        Path start = Paths.get(%22/Users/benny/Documents%22);%0A        int maxDepth = 5;%0A        Files%0A            .find(start, maxDepth, (path, attr) -%3E%0A                String.valueOf(path).endsWith(%22xls%22))%0A            .sorted()%0A            .forEach(System.out::println);%0A    %7D%0A%0A    private static void test6() throws IOException %7B%0A        Files%0A            .list(Paths.get(%22/usr%22))%0A            .sorted()%0A            .forEach(System.out::println);%0A    %7D%0A%0A    private static void test5() throws IOException %7B%0A        Files%0A            .lines(Paths.get(%22/foo%22, %22bar%22))%0A            .filter(line -%3E line.startsWith(%22A%22))%0A            .forEach(System.out::println);%0A    %7D%0A%0A    private static void test4() %7B%0A        Stream%0A            .of(new BigDecimal(%221.2%22), new BigDecimal(%223.7%22))%0A            .mapToDouble(BigDecimal::doubleValue)%0A            .average()%0A            .ifPresent(System.out::println);%0A    %7D%0A%0A    private static void test3() %7B%0A        IntStream%0A            .range(0, 10)%0A            .average()%0A            .ifPresent(System.out::println);%0A    %7D%0A%0A    private static void test2() %7B%0A        IntStream%0A            .builder()%0A            .add(1)%0A            .add(3)%0A            .add(5)%0A            .add(7)%0A            .add(11)%0A            .build()%0A            .average()%0A            .ifPresent(System.out::println);%0A%0A    %7D%0A%0A    private static void test1() %7B%0A        int%5B%5D ints = %7B1, 3, 5, 7, 11%7D;%0A        Arrays%0A            .stream(ints)%0A            .average()%0A            .ifPresent(System.out::println);%0A    %7D%0A%7D%0A

Add more stream examples