The moose likes Servlets and the fly likes Array help Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "Array help" Watch "Array help" New topic

Array help

Zoe Peng
Ranch Hand

Joined: Nov 27, 2000
Posts: 112
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()));
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

Joined: Apr 05, 2001
Posts: 118
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

Phil Hanna<BR>Sun Certified Programmer for the Java 2 Platform<BR>Author of :<BR><A HREF="" TARGET=_blank rel="nofollow">JSP: The Complete Reference</A><BR><A HREF="" TARGET=_blank rel="nofollow">Instant Java Servlets</A>
Zoe Peng
Ranch Hand

Joined: Nov 27, 2000
Posts: 112
I got it.
It works. I went through array concepts and string again..
It is sorta covered in the JavaRanch Style Guide.
subject: Array help
jQuery in Action, 3rd edition