09 April 2004 - java_dev (original) (raw)

is there a way i can access a specific token within a StringTokenizer object? I need to be careful with setting up a loop, because not all the tokens will recieve the same treatment.

I am working with input monetary amounts, so my delimiter is "."

I know I can use sToken.nextToken() to immediately work with the dollars (the first token of the two within the object), but how do I work with the second token alone?

My textbook only lists the following methods for the StringTokenizer class:
countTokens(): int
hasMoreTokens(): boolean
nextToken(): String
nextToken(delim: String): String

Are there other methods I'm not aware of beyond these?

Ultimately I need to get the second token, parse it to double, and then work with just the cents, etc.

Basically, what kind of loop / methods can I set up for sToken to do this?

Thanks in advance.