@@ -0,0 +1,1434 @@
+package com.yutax77.java8_ans.chap2;%0A%0Aimport static org.hamcrest.CoreMatchers.is;%0Aimport static org.junit.Assert.*;%0A%0Aimport java.io.IOException;%0Aimport java.net.URISyntaxException;%0Aimport java.nio.charset.StandardCharsets;%0Aimport java.nio.file.Files;%0Aimport java.nio.file.Paths;%0Aimport java.util.Arrays;%0Aimport java.util.List;%0A%0Aimport org.junit.Before;%0Aimport org.junit.Test;%0A%0Apublic class Ans3Test %7B%0A    private List%3CString%3E words;%0A    %0A    @Before%0A    public void setUp() throws IOException, URISyntaxException %7B%0A        String contents = new String(Files.readAllBytes(%0A        %09Paths.get(getClass().getResource(%22alice.txt%22).toURI())),%0A        %09StandardCharsets.UTF_8); // Read file into string%0A        words = Arrays.asList(contents.split(%22%5B%5C%5CP%7BL%7D%5D+%22));%0A    %7D%0A    %0A    @Test%0A    public void benchStream() throws IOException, URISyntaxException %7B%0A%09long start = System.nanoTime();%0A%09long count = words.stream().filter(w -%3E w.length() %3E 12).count();%0A%09long end = System.nanoTime();%0A%09%0A%09assertThat(count, is(33L));%0A%09%0A%09System.out.println(%22Stream:%22 + (end - start) / 1000000  + %22 ms%22);%0A    %7D%0A    %0A    @Test%0A    public void benchParallelStream() throws IOException, URISyntaxException %7B%0A%09long start = System.nanoTime();%0A%09long count = words.parallelStream().filter(w -%3E w.length() %3E 12).count();%0A%09long end = System.nanoTime();%0A%09%0A%09assertThat(count, is(33L));%0A%09%0A%09System.out.println(%22ParallelStream:%22 + (end - start) / 1000000 + %22 ms%22);%0A    %7D%0A%7D%0A

Answer chap.2-3