Skip to content

Commit b9ac0f3

Browse files
committed
String stuff
1 parent 34a42c5 commit b9ac0f3

File tree

1 file changed

+35
-0
lines changed

1 file changed

+35
-0
lines changed
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
package com.winterbe.java8.samples.misc;
2+
3+
import java.util.function.Predicate;
4+
import java.util.regex.Pattern;
5+
6+
/**
7+
* @author Benjamin Winterberg
8+
*/
9+
public class String1 {
10+
11+
public static void main(String[] args) {
12+
testJoin();
13+
testPatternPredicate();
14+
testPatternSplit();
15+
}
16+
17+
private static void testPatternSplit() {
18+
Pattern.compile(":")
19+
.splitAsStream("foobar:foo:bar")
20+
.sorted()
21+
.forEach(System.out::println);
22+
}
23+
24+
private static void testPatternPredicate() {
25+
Pattern pattern = Pattern.compile(".*123.*");
26+
Predicate<String> predicate = pattern.asPredicate();
27+
System.out.println(predicate.test("a123b"));
28+
System.out.println(predicate.test("boom"));
29+
}
30+
31+
private static void testJoin() {
32+
String string = String.join(";", "a", "b", "c", "d");
33+
System.out.println(string);
34+
}
35+
}

0 commit comments

Comments
 (0)