Google Guava Splitter Example

import com.google.common.base.Splitter;

public class SplitterTest {

public static void main(String[] args) {

String str = “a,b,c,d,e”;

Iterable<String> str1 = Splitter.on(“,”).split(str);

for (String str2 : str1) {

System.out.println(“String is =” + str2);

}

}

}

Output:

String is =a
String is =b
String is =c
String is =d
String is =e

Leave a Reply

Your email address will not be published. Required fields are marked *

− 5 = 3