It is very surprising but I faced one problem using StringTokenizer class. I used 2 parameter constructor i.e. StringTokenizer("This is my : first token ::: This is my : second token",":::"); Now in above case if I tokenize the string it gives me 4 tokens as
This is my first token This is my second token
Instead it should give me
This is my : first token This is my : second token
I am confused why it is tokenizing for single ':' as my seperator token is ':::'
Any body has idea ?
Joined: Feb 07, 2007
Hi, I'm also puzzled i tried the same thing with some thing like this
And my output turned out to be This is my b first token c This is my dj second token May be the delim matches the first occurence .Anyways I would do this with String Split or regex
Joined: Aug 05, 2005
The second parameter is a list of characters to use as delimiters, not a String to be used as a delimiter.
The String.split method is probably better for what you want to do.