Split a string : Split « Regular Expressions « Java Tutorial






public class MainClass {
  public static void main(String args[]) {
    String splitPattern = ",";
    String sentence = "This is a test, and that is another test.";
    String[] tokens = sentence.split(splitPattern);
    for (String s : tokens) {
      System.out.println(s);
    }
  }
}








8.8.Split
8.8.1.Split a string