String s = "test -||- testing again -|- test_1 -||- testing again_1";
StringTokenizer tokenizer = new StringTokenizer(s,"-|-");
System.out.println(tokenizer.countTokens());
while(tokenizer.hasMoreTokens()) {
System.out.println(tokenizer.nextToken());
}
Output:
4
test
testing again
test_1
testing again_1
Shouldn't the count be 2..?
And i tried printing the tokens, and all the strings got printed. Not only that which should be considered as a token.
I also read from the java API doc the following,
delimiter characters serve to separate tokens. A token is a maximal sequence of consecutive characters that are not delimiters
if such is the case shouldn't my delimeter "-|-" be used to split the strings into 2?