/Users/lyon/j4p/src/bookExamples/ch06RefDataTypes/TokeizerExample.java
|
1 package bookExamples.ch06RefDataTypes;
2
3 import java.util.StringTokenizer;
4
5 /**
6 * DocJava, Inc.
7 * http://www.docjava.com
8 * Programmer: dlyon
9 * Date: Sep 8, 2004
10 * Time: 7:16:58 PM
11 */
12 public class TokeizerExample {
13 public static void main(String[] args) {
14 String s = "marc ed, byron, Hello, hi, Herman:Munster damian, randeep";
15 System.out.println(s);
16 StringTokenizer st = new StringTokenizer(s,", ");
17 int n = st.countTokens();
18 System.out.println("n="+n);
19 while (st.hasMoreTokens())
20 System.out.println(st.nextToken());
21 }
22 }
23