J
Jim Crowell
I have a method to unpack a String via a given String delimiter. It works
fine but it used the 'String' Class 'indexOf' and 'substring' Methods within
a 'for' loop.
To make this method more efficient I tried to substitute the
'StringTokenizer' Class. Easy enough but it looks like the following input
String returns 3 token where I would expect 4 tokens:
"AA,BB,,1," with delimiter = ","
Also, the following String returns 3 Tokens where I would expect 4:
",BB,CC,1," with delimiter = ","
With my code I use an 'if' condition before I unpack to ensure that the
string ends with the delimiter but for 'StringTokenizer' I see that the
following input String returns 4 tokens:
"AA,BB,CC,1" with delimiter = ","
I assume that a token must have 1 or more characters and that I must return
to my original code.
Is there a way to make 'StringTokenizer' recognize consecutive delimiters
and return a null String [e.g. ""] as a token?
Thanks
Jim.
fine but it used the 'String' Class 'indexOf' and 'substring' Methods within
a 'for' loop.
To make this method more efficient I tried to substitute the
'StringTokenizer' Class. Easy enough but it looks like the following input
String returns 3 token where I would expect 4 tokens:
"AA,BB,,1," with delimiter = ","
Also, the following String returns 3 Tokens where I would expect 4:
",BB,CC,1," with delimiter = ","
With my code I use an 'if' condition before I unpack to ensure that the
string ends with the delimiter but for 'StringTokenizer' I see that the
following input String returns 4 tokens:
"AA,BB,CC,1" with delimiter = ","
I assume that a token must have 1 or more characters and that I must return
to my original code.
Is there a way to make 'StringTokenizer' recognize consecutive delimiters
and return a null String [e.g. ""] as a token?
Thanks
Jim.