Tokenizing a String : String Tokenize « Data Type « Java Tutorial






public class MainClass{

  public static void main(String[] arg){
    String text = "to be or not to be, that is the question.";
    String[] words = text.split("[, .]", 0); // Delimiters are comma, space, or period
    
    for(String s: words){
      System.out.println(s);
    }
  }

}
to
be
or
not
to
be

that
is
the
question








2.24.String Tokenize
2.24.1.Tokenizing a String
2.24.2.Delimiters are comma, space, or period: '[, .]'
2.24.3.Parse Comma Delimited List