472,139 Members | 1,810 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,139 software developers and data experts.

StringBuffer Question

Hi All

I just want to know if someone can help me to empty
the values in a SringBuffer

Thanks
Johnny
Jul 17 '05 #1
4 10411
IS
Have you considered using delete(0, int end) ?

IS

"johnny luiz" <jo*****@nupay.co.za> wrote in message
news:8a********************@is.co.za...
Hi All

I just want to know if someone can help me to empty
the values in a SringBuffer

Thanks
Johnny

Jul 17 '05 #2


While it was 14/11/03 1:35 pm throughout the UK, johnny luiz sprinkled
little black dots on a white screen, and they fell thus:
Hi All

I just want to know if someone can help me to empty
the values in a SringBuffer


What values?

To empty a StringBuffer, use setLength(0) on it.

Or do you mean something else?

Stewart.

--
My e-mail is valid but not my primary mailbox, aside from its being the
unfortunate victim of intensive mail-bombing at the moment. Please keep
replies on the 'group where everyone may benefit.
Jul 17 '05 #3
I would like to know
how to empty out a strring buffer.

i am developing an application that uses serial com communication
that receives infor from the port. i write the data into a stringbuffer.
when new info is received at the port i read it into the stringbuffer
but the previous data is still in the stringbuffer. ia don't what the
previous info
there.

I have tried both the above mentioned scenarios adn they didnt
help

"Stewart Gordon" <sm*******@yahoo.com> wrote in message
news:bp**********@sun-cc204.lut.ac.uk...


While it was 14/11/03 1:35 pm throughout the UK, johnny luiz sprinkled
little black dots on a white screen, and they fell thus:
Hi All

I just want to know if someone can help me to empty
the values in a SringBuffer


What values?

To empty a StringBuffer, use setLength(0) on it.

Or do you mean something else?

Stewart.

--
My e-mail is valid but not my primary mailbox, aside from its being the
unfortunate victim of intensive mail-bombing at the moment. Please keep
replies on the 'group where everyone may benefit.

Jul 17 '05 #4

"johnny luiz" <jo*****@nupay.co.za> wrote in message
news:e4********************@is.co.za...
I would like to know
how to empty out a strring buffer.

i am developing an application that uses serial com
communication that receives infor from the port. i
write the data into a stringbuffer.

when new info is received at the port i read it into
the stringbuffer but the previous data is still in the
stringbuffer. ia don't what the previous info there.

I have tried both the above mentioned scenarios adn
they didnt help


StringBuffer sb("ABCDE");

// 1) Empty buffer using 'delete'
sb.delete(0, sb.length());

// or:

// 2) Empty buffer using 'replace'
sb.replace(0, sb.length(), "");

// or:

// 3) Empty buffer using 'setLength'
sb.setLength(0);

All three of these approaches have the effect of 'emptying' the StringBuffer
object of its contents [of characters] but do not alter its capacity, the
currently-available storage for additional characters.

Your problem is likely to have other causes. Perhaps if you posted the
relevant piece of source code constructive suggestions could be made.

I hope this helps.

Anthony Borla

Jul 17 '05 #5

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

3 posts views Thread by Stevey | last post: by
10 posts views Thread by glenn | last post: by
2 posts views Thread by helpamit | last post: by
2 posts views Thread by dksuresh1983 | last post: by
reply views Thread by leo001 | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.