aspose file tools*
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


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "Array help" Watch "Array help" New topic
Author

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()));
...
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

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="http://www.amazon.com/exec/obidos/ASIN/0072127686/electricporkchop/107-3548162-1137317" TARGET=_blank rel="nofollow">JSP: The Complete Reference</A><BR><A HREF="http://www.amazon.com/exec/obidos/ASIN/0072124253/electricporkchop/107-3548162-1137317" TARGET=_blank rel="nofollow">Instant Java Servlets</A>
Zoe Peng
Ranch Hand

Joined: Nov 27, 2000
Posts: 112
Thanks.
I got it.
It works. I went through array concepts and string again..
finally..Bingo!
--Zoe
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Array help
 
Similar Threads
Name the mutable and immutable Classes
Options on Opening Files
How to Compare StringBuffer object with String Object
Reading and displaying Strings from a file
a simple quiz on string equals