File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

finding token data type (StringTokenizer)

 
Pip Vo
Greenhorn
Posts: 12
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 8521
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What do you WANT G7790 to parse to?
Have you looked into using a StringTokenizer, perhaps inside the StreamTokenizer calls?
 
Pip Vo
Greenhorn
Posts: 12
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 8521
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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?
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic