wood burning stoves 2.0*
The moose likes Beginning Java and the fly likes finding token data type (StringTokenizer) Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "finding token data type (StringTokenizer)" Watch "finding token data type (StringTokenizer)" New topic
Author

finding token data type (StringTokenizer)

Pip Vo
Greenhorn

Joined: Jul 18, 2001
Posts: 12
Does anyone know how to find the data type of
st.nextToken in the code below? I can't use
streamTokenizer's TT_WORD or TT_NUMBER b/c need
to parse words like G7790 that have both #s and
letters and streamTokenizer gets confused. Need something specific to stringTokenizer. Searched Sun's page w/ no luck. TIA

[ January 29, 2002: Message edited by: Cindy Glass ]
Cindy Glass
"The Hood"
Sheriff

Joined: Sep 29, 2000
Posts: 8521
What do you WANT G7790 to parse to?
Have you looked into using a StringTokenizer, perhaps inside the StreamTokenizer calls?
Pip Vo
Greenhorn

Joined: Jul 18, 2001
Posts: 12
Cindy,
Thanks for the reply.
I need to find out what tokens are doubles
and put them in the data1 array. Anything else
(like G7889) goes into the name1 array.
I've used StreamTokenizer in an earlier version,
and something like G7889 gets split up into G and 7889 which I don't want. So am not sure about
using again and trying to put StringTokenizer
inside it.
Pip
Cindy Glass
"The Hood"
Sheriff

Joined: Sep 29, 2000
Posts: 8521
Oh, I think that I get it.
Can't you just use StringTokenizer, and then check each token to see if you can Long.parseLong(st.nextToken()) and if it pulls a NumberFormatException - then put it in as a String?
 
Consider Paul's rocket mass heater.
 
subject: finding token data type (StringTokenizer)