StringTokenizer: nextToken() : StringTokenizer « java.lang « Java by API






StringTokenizer: nextToken()

/*
 * Output:
 * 
a  1
b  2
  
 */

import java.util.StringTokenizer;

public class MainClass {

  public static void main(String args[]) {
    String in = "a=1;" + "b=2";

    StringTokenizer st = new StringTokenizer(in, "=;");
    while (st.hasMoreTokens()) {
      String key = st.nextToken();
      String val = st.nextToken();
      System.out.println(key + "\t" + val);
    }
  }
}


           
       








Related examples in the same category

1.new StringTokenizer(String str, String delim)
2.StringTokenizer: hasMoreTokens()