Skip to content

Commit 0c4f633

Browse files
committed
Files examples
1 parent fee263c commit 0c4f633

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

src/com/winterbe/java8/samples/misc/Files1.java

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,17 @@ public static void main(String[] args) throws IOException {
2121
testReader();
2222
testWriter();
2323
testReadWriteLines();
24+
testReaderLines();
25+
}
26+
27+
private static void testReaderLines() throws IOException {
28+
try (BufferedReader reader =
29+
Files.newBufferedReader(Paths.get("res", "nashorn1.js"))) {
30+
long countPrints = reader.lines()
31+
.filter(line -> line.contains("print"))
32+
.count();
33+
System.out.println(countPrints);
34+
}
2435
}
2536

2637
private static void testWriter() throws IOException {

0 commit comments

Comments
 (0)