• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Help...StringTokenizer

 
Zoe Peng
Ranch Hand
Posts: 112
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 49
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic