This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes I/O and Streams and the fly likes Parsing of StringBuffer(URGENT) Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » I/O and Streams
Bookmark "Parsing of StringBuffer(URGENT)" Watch "Parsing of StringBuffer(URGENT)" New topic
Author

Parsing of StringBuffer(URGENT)

Angela Jessi
Ranch Hand

Joined: Nov 27, 2000
Posts: 428
Hi,
I have defined String Buffer of 2K capacity. Server is send me data withing that capacity of string Buffer. After StringBuffer recieves data from the server on client side, I want to parse it. I have delimeter ":" to parse the stringBuffer?
I tried to use StringTokenizer, Substring. But I can't get it.
Here is my example:
import java.applet.Applet;
import java.util.*;
public class sbDemo extends Applet{
StringBuffer sb;
StringTokenizer st;
public void init(){
sb.append("Anuja:shah:Konica:Business:Technology");
st = new StringTokenizer(sb,":");
while(st.hasMoreTokens()){
System.out.println("The String is --->" + st.nextToken());
}
}
}
Thanks,
Angela
Michael Dean
Greenhorn

Joined: Jul 31, 2000
Posts: 9
Angela: modify your code as follows:
st = new StringTokenizer(sb.toString(),":");
StringTokenizer takes arguments of type String, not StringBuffer...
HTH,
Michael

 
 
subject: Parsing of StringBuffer(URGENT)
 
Similar Threads
need to transfer productID from url to action class in struts 2
String conversion
StringBuffer Very Urgent please
how to print in capital of each frist word
StringIndexOut OfBoundsException