• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Parsing of StringBuffer(URGENT)

 
Angela Jessi
Ranch Hand
Posts: 428
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Angela: modify your code as follows:
st = new StringTokenizer(sb.toString(),":");
StringTokenizer takes arguments of type String, not StringBuffer...
HTH,
Michael

 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic