When I ran the following code I found something strange.
The output of below program is token1=AAAAA token2=BBBBB|
However, From my understanding, it should be token1=AAAAA token2=BBBBB|DUMMY
public class TestToken {
public static void main(final String[] args) {
final String delim = "DELIM";
String token1 = "AAAAA";
String token2 = "BBBBB|DUMMY";
final String input = token1 + delim + token2;
final StringTokenizer tokenizer = new StringTokenizer(input, delim);
final String text1 = tokenizer.nextToken();
final String text2 = tokenizer.nextToken();
System.out.println("token1=" + text1);
System.out.println("token2=" + text2);
System.out.println();
}
}
Can some one explain me how to fix this problem and why it is behaving like this ?