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

 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Parsing of StringBuffer(URGENT)