Perfect. It worked. Thanks.
I have another question. What if my token is composed of more than one characters?
|
Code:
|
String s= "I am new to Java. Are you good in Java, if yes please help me.";
String delim = "Java";
StringTokenizer tokens = new StringTokenizer(s, delim);
while(tokens.hasMoreTokens())
System.out.println(tokens.nextToken()); |
Output:
|
Code:
|
Welcome
I
m new to
. Are you good in
, if yes ple
se help me. |
Actually "Java" is not treated as a token but 4 different tokens (each character is a token). How to handle this?