Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Array help

 
Zoe Peng
Ranch Hand
Posts: 112
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi, there,
Can anybody tell me how to do this??
Thanks in advance.
//The jsp code
/*
...
String s[] {
"param1", "value1",
"param2", "value2",
}
...
StringBuffer sb = new StringBuffer();
DataOutputStream printout = new DataOutputStream(urlConn.getOutputStream());
....
sb = new StringBuffer();
BufferedReader in = new BufferedReader(new inputStreamReader(urlConn.getInputStream()));
...
out.println(sb);
*/
the results are "1478,1528,1530,1531,"
s[0] = param1; s[1] = value1.
the server return the string results to me based on parameters I sent.
How can I make a new array to become this?
s2[1478]; s2[1528]...

 
Phil Hanna
Ranch Hand
Posts: 118
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Not sure I fully understand your question, but if you want to load the contents of a comma-separated string into an array, you can use StringTokenizer:


------------------
Phil Hanna
Sun Certified Programmer for the Java 2 Platform
Author of :
JSP: The Complete Reference
Instant Java Servlets
 
Zoe Peng
Ranch Hand
Posts: 112
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks.
I got it.
It works. I went through array concepts and string again..
finally..Bingo!
--Zoe
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic