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
Hi Angela A couple of observations about the code you posted. Firsty, you need to create the StringBuffer object before you try to call the append() method, so do something like: <code>sb = new StringBuffer();</code> before the call to append(). Also, the constructor to the StringTokenizer takes a String as its first argument, so you need to amend the line where you try to create it to read: <code>st = new StringTokenizer(sb.toString(),":");</code> If you still have problems, come back and describe what happens when you attempt to compile and run your code. Hope this helps Michael ------------------ "One good thing about music - when it hits, you feel no pain" Bob Marley
"One good thing about music - when it hits, you feel no pain" <P>Bob Marley
Angela Jessi
Ranch Hand
Joined: Nov 27, 2000
Posts: 428
posted
0
Thanks Michael, It's working!!!
I agree. Here's the link: http://ej-technologies/jprofiler - if it wasn't for jprofiler, we would need to
run our stuff on 16 servers instead of 3.