File tree Expand file tree Collapse file tree 1 file changed +14
-2
lines changed Expand file tree Collapse file tree 1 file changed +14
-2
lines changed Original file line number Diff line number Diff line change @@ -18,7 +18,7 @@ It provides a set of components that mimic Unix commands (and more).
18
18
19
19
# How to use it?
20
20
21
- You can use UnixStream in two ways:
21
+ You can use UnixStream in 3 ways:
22
22
23
23
#### 1. Either unixifiy your stream and process it the unix way:
24
24
@@ -37,7 +37,7 @@ UnixStream.unixify(stream)
37
37
// 2 baz
38
38
```
39
39
40
- #### 2. Or write your pipelines as you read them
40
+ #### 2. Or write your pipelines as you read them:
41
41
42
42
``` java
43
43
// cat input.txt | grep a | sort | uniq | nl > output.txt
@@ -50,6 +50,18 @@ UnixStream.cat("input.txt")
50
50
.to(file(" output.txt" ));
51
51
```
52
52
53
+ #### 3. Or use functions and predicates provided by UnixStream with the standard Stream API:
54
+
55
+ ``` java
56
+ Stream . of(" 1,foo" , " 2,bar" )
57
+ .filter(grep(" a" ))
58
+ .map(cut(" ," , 2 ))
59
+ .forEach(System . out:: println);
60
+
61
+ // prints:
62
+ // bar
63
+ ```
64
+
53
65
# Where to find it?
54
66
55
67
Add the following maven dependency to your project:
You can’t perform that action at this time.
0 commit comments