"Rick" <as******@hotmail.com> wrote in message news:<3f***********************@news.xs4all.nl>...
Hi,
I'm having a little problem with the string tokenizer. For example, I got
this data string :
"0#0#0#0####0#0#0#.. and so on....."
How obvious, the # char will be the delimiter. But as you can see, at some
points there are two or more brackets pasted together. I want to let the
program return an empty string but the tokenizer just passes these brackets.
How to tell him he got to give the empty places as well?
Greetings,
Rick
If you check in the documentation IIRC you'll find an extra parameter
which can be used to tell StringTokenizer to return the delimiters as
well as the tokens. Using this, plus a little extra work, it is
possible to figure out whether two delimiters have been passed in a
row, without any token in between, and treat this case as an empty
token.
One final thing to note is an issue if the string ends with a delimiter,
make sure you handle the implied empty token which 'follows' it. You
could do this by always appending a '#' (the delimiter) onto the end of
the tokenized string, so any implied empty token at the end of the string
could be processed without need to write special case code to detect it.
-FISH- ><>