Skip to content

Commit d5062cc

Browse files
committed
fix
1 parent 85ab48e commit d5062cc

7 files changed

Lines changed: 30 additions & 17 deletions

File tree

‎streams/FileToWordsRegexp.java‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ public Stream<String> stream() {
2222
public static void
2323
main(String[] args) throws Exception {
2424
FileToWordsRegexp fw =
25-
new FileToWordsRegexp("Cheese.dat");
25+
new FileToWordsRegexp("/Users/zss/Projects/OnJava8-Examples/streams/Cheese.dat");
2626
fw.stream()
2727
.limit(7)
2828
.map(w -> w + " ")

‎streams/FileToWordsTest.java‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,11 @@
77
public class FileToWordsTest {
88
public static void
99
main(String[] args) throws Exception {
10-
FileToWords.stream("Cheese.dat")
10+
FileToWords.stream("/Users/zss/Projects/OnJava8-Examples/streams/Cheese.dat")
1111
.limit(7)
1212
.forEach(s -> System.out.format("%s ", s));
1313
System.out.println();
14-
FileToWords.stream("Cheese.dat")
14+
FileToWords.stream("/Users/zss/Projects/OnJava8-Examples/streams/Cheese.dat")
1515
.skip(7)
1616
.limit(2)
1717
.forEach(s -> System.out.format("%s ", s));

‎streams/Matching.java‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ static void show(Matcher match, int val) {
2020
n -> n < val));
2121
}
2222
public static void main(String[] args) {
23+
2324
show(Stream::allMatch, 10);
2425
show(Stream::allMatch, 4);
2526
show(Stream::anyMatch, 2);

‎streams/Peeking.java‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
class Peeking {
77
public static void
88
main(String[] args) throws Exception {
9-
FileToWords.stream("Cheese.dat")
9+
FileToWords.stream("/Users/zss/Projects/OnJava8-Examples/streams/Cheese.dat")
1010
.skip(21)
1111
.limit(4)
1212
.map(w -> w + " ")

‎streams/SortedComparator.java‎

Lines changed: 18 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,18 +2,27 @@
22
// (c)2021 MindView LLC: see Copyright.txt
33
// We make no guarantees that this code is fit for any purpose.
44
// Visit http://OnJava8.com for more book information.
5+
56
import java.util.*;
67

78
public class SortedComparator {
8-
public static void
9-
main(String[] args) throws Exception {
10-
FileToWords.stream("Cheese.dat")
11-
.skip(10)
12-
.limit(10)
13-
.sorted(Comparator.reverseOrder())
14-
.map(w -> w + " ")
15-
.forEach(System.out::print);
16-
}
9+
public static void
10+
main(String[] args) throws Exception {
11+
FileToWords.stream("/Users/zss/Projects/OnJava8-Examples/streams/Cheese.dat")
12+
.skip(10)
13+
.limit(10)
14+
.sorted(Comparator.reverseOrder())
15+
.map(w -> w + " ")
16+
.forEach(System.out::print);
17+
System.out.println();
18+
FileToWords.stream("/Users/zss/Projects/OnJava8-Examples/streams/Cheese.dat")
19+
.skip(10)
20+
.limit(10)
21+
.sorted(String::compareTo
22+
)
23+
.map(w -> w + " ")
24+
.forEach(System.out::print);
25+
}
1726
}
1827
/* Output:
1928
you what to the that sir leads in district And

‎streams/SpecialCollector.java‎

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,13 @@ public class SpecialCollector {
99
public static void
1010
main(String[] args) throws Exception {
1111
ArrayList<String> words =
12-
FileToWords.stream("Cheese.dat")
13-
.collect(ArrayList::new,
12+
FileToWords.stream("/Users/zss/Projects/OnJava8-Examples/streams/Cheese.dat")
13+
.collect(
14+
ArrayList::new,
1415
ArrayList::add,
15-
ArrayList::addAll);
16+
ArrayList::addAll
17+
);
18+
System.out.println(words);
1619
words.stream()
1720
.filter(s -> s.equals("cheese"))
1821
.forEach(System.out::println);

‎streams/TreeSetOfWords.java‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ public class TreeSetOfWords {
1010
public static void
1111
main(String[] args) throws Exception {
1212
Set<String> words2 =
13-
Files.lines(Paths.get("TreeSetOfWords.java"))
13+
Files.lines(Paths.get("/Users/zss/Projects/OnJava8-Examples/streams/TreeSetOfWords.java"))
1414
.flatMap(s -> Arrays.stream(s.split("\\W+")))
1515
.filter(s -> !s.matches("\\d+")) // No numbers
1616
.map(String::trim)

0 commit comments

Comments
 (0)