Thanks for the info. I guess the tokens were being created for a set of
character delimiters within the string rather than the entire delimiter
string. I did not see that documented anywhere.

Note that StringTokenizer is not deprecated. There is language in the
JavaDoc to use String#split but it is not deprecated.

Todd Allen
Electronic Data Processing Services

"Dan Kimmel"
<dkimmel@rjssoftw> To
Sent by: "Java Programming on and around the
java400-l-bounces iSeries / AS400" <java400-l@xxxxxxxxxxxx>

2009-09-30 15:47 Subject
RE: String tokenizer problem

Please respond to
Java Programming
on and around the
iSeries / AS400

In StringTokenizer, the second String in the constructor is a set of
CHARACTER delimiters presented in the form of a string. new
StringTokenizer(someString, " ;." will break the string into tokens for
every space, semicolon, or dot contained in someString. StringTokenizer
is deprecated in favor of String.split() which takes a regex as

-----Original Message-----
From: java400-l-bounces@xxxxxxxxxxxx
[mailto:java400-l-bounces@xxxxxxxxxxxx] On Behalf Of TAllen@xxxxxxxxxxxx
Sent: Wednesday, September 30, 2009 1:09 PM
To: Java Programming on and around the iSeries / AS400
Subject: String tokenizer problem

I'm having some trouble with the StringTokenizer. As far as I can tell
there is something wacky going on due to the + or : in the delimiter.
I have the following string:
Sep 29, 2009 7:00 PM GMT+00:00 Sep 30, 2009 7:30 PM GMT+00:00

I am using "GMT+00:00" (no quotes) as the delimiter.

The String#split method correctly splits the string in to the array
elements using a simple regex:
String[] tokens = text.split("GMT\\+00:00");

The StringTokenizer splits on the first double zero in 2009 and then
stops at the colon in the time next:
StringTokenizer t = new StringTokenizer(text, "GMT+00:00");

The 1st two tokens are:
Sep 29, 2
9 7

Has anyone seen this behavior before? Am I missing something obvious?

Todd Allen
Electronic Data Processing Services

This communication and any transmitted documents are intended to be confidential. If there is a problem with this transmission, please contact the sender. If the reader of this message is not the intended recipient, or the employee or agent responsible to deliver it to the intended recipient, you are hereby notified that any dissemination, distribution or copying of this communication is strictly prohibited.

As an Amazon Associate we earn from qualifying purchases.

This thread ...


Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

This mailing list archive is Copyright 1997-2022 by and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].

Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.