Hey!
Ramanathan Subbarayan, this is off-topic for SERVLET-INTEREST.
I couldn't let it slide though because there are two glaring
mistakes here. Be careful when you respond to a question
that you are absolutely certain that you are correct.
There is no method setSize().
I am guessing that you are referring to setLength().
This is also is not correct.
If you are worried about allocating memory, you are
better off using delete() ("I think. I don't have the JDK
source code available to be certain. You might want to
check on your own. Let me know if I am wrong.).
With delete(), you are just removing the characters and
not changing the buffer size.
Sans adieu,
Danny Rubis
Ramanathan Subbarayan wrote:
> buffer.setSize(0)
>
> Sushil Singh wrote:
>
> > Thanks, but once the StringBuffer is having some data and I printed using
> > System.out, for the next time I have to rebuild the StringBuffer by eliminating
> > the previous content, what method I should use.
> > StringBuffer temp = new StringBuffer();
> > temp.append("test1");
> > temp.append("test2");
> > System.out.println(temp);
> > temp = new StringBuffer();
> > temp.append("test111");
> > temp.append("test222");
> > System.out.println(temp);
> >
> > Is there any way, to directly overwrite the StringBuffer content with new
> > content.
> >
> > Thanks in advance.
> >
> > Sushil
> >
> > [EMAIL PROTECTED] wrote:
> >
> > > Hi,
> > >
> > > It shd be the following way:
> > >
> > > StringBuffer temp = new StringBuffer();
> > >
> > > temp.append("test1");
> > >
> > > temp.append("test2");
> > >
> > > System.out.println(temp);
> > >
> > > BFN
> > >
> > > Naga
> > >
> > > From: [EMAIL PROTECTED] on 21/11/2000 23:52 GMT
> > >
> > > Please respond to [EMAIL PROTECTED]
> > >
> > > To: [EMAIL PROTECTED]
> > > cc:
> > > Subject: StringBuffer Question
> > >
> > > Hi,
> > >
> > > I have a question regarding String and StringBuffer class. Recently I
> > > read that we should not use "+" concatenation since it will create
> > > temporary objects, instead we should use StringBuffer. My JSP is
> > > producing series of System.out.println, like:
> > > .......
> > > some process
> > > ....
> > > System.out.println(new
> > > StringBuffer("test").append("test1").append("test2"));
> > > ----
> > > System.out.println(new
> > > StringBuffer("test3").append("test4").append("test5"));
> > > ----
> > > and so on.
> > >
> > > Now my question is that whether I should have one StringBuffer variable,
> > > append it and then displays or everytime "new StringBuffer". Which way
> > > is the best, any feedback will be highly appreciated.
> > >
> > > Thanks in advance.
> > >
> > > Sushil
> > >
> > > ___________________________________________________________________________
> > > To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
> > > of the message "signoff SERVLET-INTEREST".
> > >
> > > Archives: http://archives.java.sun.com/archives/servlet-interest.html
> > > Resources: http://java.sun.com/products/servlet/external-resources.html
> > > LISTSERV Help: http://www.lsoft.com/manuals/user/user.html
> > >
> > > ___________________________________________________________________________
> > > To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
> > > of the message "signoff SERVLET-INTEREST".
> > >
> > > Archives: http://archives.java.sun.com/archives/servlet-interest.html
> > > Resources: http://java.sun.com/products/servlet/external-resources.html
> > > LISTSERV Help: http://www.lsoft.com/manuals/user/user.html
> >
> > ___________________________________________________________________________
> > To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
> > of the message "signoff SERVLET-INTEREST".
> >
> > Archives: http://archives.java.sun.com/archives/servlet-interest.html
> > Resources: http://java.sun.com/products/servlet/external-resources.html
> > LISTSERV Help: http://www.lsoft.com/manuals/user/user.html
>
> ___________________________________________________________________________
> To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
> of the message "signoff SERVLET-INTEREST".
>
> Archives: http://archives.java.sun.com/archives/servlet-interest.html
> Resources: http://java.sun.com/products/servlet/external-resources.html
> LISTSERV Help: http://www.lsoft.com/manuals/user/user.html
___________________________________________________________________________
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff SERVLET-INTEREST".
Archives: http://archives.java.sun.com/archives/servlet-interest.html
Resources: http://java.sun.com/products/servlet/external-resources.html
LISTSERV Help: http://www.lsoft.com/manuals/user/user.html