File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes I/O and Streams and the fly likes Help...StringTokenizer Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » I/O and Streams
Bookmark "Help...StringTokenizer " Watch "Help...StringTokenizer " New topic


Zoe Peng
Ranch Hand

Joined: Nov 27, 2000
Posts: 112
The nextToken() checks the last token for me.
but, I have more than one tokens. How can get all the tokens??
is it possible? do I have another way to do this?
Thanks in advance.
String values = sb.toString();
StringTokenizer st = new StringTokenizer(values, ",");
//the values are 1478,1528,1530,1531,1532,1567,2125
//String[] sa = new String[st.countTokens()];
//for (int i = 0; i < sa.length; i++)
// sa[i] = st.nextToken();

String[] s2 =
"ProjectID", request.getParameter("ProjectID"),
"TypeID", request.getParameter("TypeID"),
"ObjectNum", st.nextToken()
//What can I put here to get all of the tokens??
//here just get 1478;
//I do want to get 1478, 1528...
Ravikiran Choppalli
Ranch Hand

Joined: Nov 18, 2000
Posts: 49
Try to put all the tokens in an array
int j=0 ;
while (st.hasMoreTokens())
tempStr[j] = st.nextToken() ;
j++ ;
and then use the array to access all the elements later.
- Ravi

I agree. Here's the link:
subject: Help...StringTokenizer
It's not a secret anymore!