Skip to content

Commit c19ecd1

Browse files
authored
Create SplitStringGuavaEx.java
1 parent 831eaed commit c19ecd1

1 file changed

Lines changed: 20 additions & 0 deletions

File tree

strings/SplitStringGuavaEx.java

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
package com.zetcode;
2+
3+
import com.google.common.base.Splitter;
4+
5+
// needs Guava dependency
6+
7+
public class SplitStringGuavaEx {
8+
9+
public static void main(String[] args) {
10+
11+
var input = " falcon, \t\tforest\t, \t\t, moderate, sky\n";
12+
13+
var result = Splitter.on(',')
14+
.trimResults()
15+
.omitEmptyStrings()
16+
.splitToList(input);
17+
18+
result.forEach(System.out::println);
19+
}
20+
}

0 commit comments

Comments
 (0)