Wednesday 13 May 2015

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

No comments:

Post a Comment