Paul said:
John C. Bollinger wrote:
Not really, especially if you have tried to use it in the kind of vanilla
parsing tasks for which it was originally intended.
I use it all over the place for vanilla parsing tasks. I don't think
I've ever had a problem with it.
Sadly, not true. The various defects are not clearly documented except in
newsgroups, where complaints about this class have the status of legend.
I'm sure I haven't been participating here as long as you have, but in
my recollection (and my Google search) that just doesn't seem to be the
case. There is one notorious event in StringTokenizer history: the
change in behavior of StringTokenizer.nextToken(String) at some point in
the Java 1.3 series. That did generate more than one thread around that
time, at least one of them quite long, so perhaps that particular
complaint is legendary. The issue of null tokens certainly has the
status of a FAQ; if that's what you mean then I already stipulated so.
No, this is not correct. The documentation doesn't accurately reflect the
behavior of the class.
I'm sorry, but I guess I'm too dense or blind. In what way is the
documentation inaccurate?
And this is not clearly documented, and it is not expected, and it is
inexcusable. To see exactly how inexcusable, one need only write a method
to parse a string on specified tokens and produce consistent results. It
just isn't that difficult.
OK, I'll give you that the fact that the class docs don't make it clear
that delimiters are formed of sequences of delimiter characters, not
strictly by individual delimiter characters. As for whether or not
that's expected, I'd say it must depend heavily on the person whose
expectations are in question. I certainly wouldn't call the behavior
"inexcusable", however, as frequently it is exactly the behavior I want,
and I'm sure I'm not such an odd bird as to be the only one who ever
wants it.
If the documentation were honestly written, it would warn people not to use
the class at all and advise that it is present in the language only because
applications have already been written using it.
"Honest"? I don't see where honesty comes into it. But as a matter of
fact: "StringTokenizer is a legacy class that is retained for
compatibility reasons although its use is discouraged in new code. It is
recommended that anyone seeking this functionality use the split method
of String or the java.util.regex package instead."
Wherefrom comes such animosity, anyway?
John Bollinger
(e-mail address removed)