StringTokenizer

How does one make a new Stringtokenizer with delimiters...

I know that the docs say new Stringtokenizer(String s, delimiters) but there's no real specification on exactly how..... for example when I did this:

Stringtokenizer(ThisString, "+=;-") it freaked out and just elimated everything...so I'm not sure what the correct syntax is....I thought of using Streamtokenizer...I believe it is...but its more than I need...this will work just fine if I can get the delimiters enter right...I need the space, a semi colon, a comma, and a hash as delimiters....

Thanks in advance....

[604 byte] By [verbitya] at [2007-11-27 3:39:22]
# 1
StringTokenizer tokens = new StringTokenizer(yourString, " ;,#");I believe that should do it.Didn't you try that? Did it not work for you?
paulcwa at 2007-7-12 8:42:43 > top of Java-index,Java Essentials,New To Java...
# 2
I tried something...lemme give that a go...is that # for a space or is that just an example...
verbitya at 2007-7-12 8:42:43 > top of Java-index,Java Essentials,New To Java...
# 3
ok this is what I did: StringTokenizer str = new StringTokenizer(s.toLowerCase(), ".,-;");and at this line:token = str.nextToken();I get a nosuchelementException
verbitya at 2007-7-12 8:42:43 > top of Java-index,Java Essentials,New To Java...
# 4
> I tried something...lemme give that a go...is that #> for a space or is that just an example...The # is because you said you wanted hash as a delimiter.
paulcwa at 2007-7-12 8:42:43 > top of Java-index,Java Essentials,New To Java...
# 5

> ok this is what I did:

>> StringTokenizer str = new StringTokenizer(s.toLowerCase(), ".,-;");

>

> and at this line:

>> token = str.nextToken();

>

> I get a nosuchelementException

That's a different issue.

Did you properly call str.hasMoreElements() first to make certain that there were any elements left?

paulcwa at 2007-7-12 8:42:43 > top of Java-index,Java Essentials,New To Java...
# 6
a sample code for demonstrating the use of StringTokenizerStringTokenizer st = new StringTokenizer(parts[0],":");while (st.hasMoreTokens()) { System.out.println(st.nextToken());}paste ur code, lets see what r u trying to achieve?
Bhannata at 2007-7-12 8:42:43 > top of Java-index,Java Essentials,New To Java...
# 7
paulcw was right i wasn't checking for more tokens.....thanks it's always something simple isn't it......
verbitya at 2007-7-12 8:42:43 > top of Java-index,Java Essentials,New To Java...