By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
438,737 Members | 1,989 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 438,737 IT Pros & Developers. It's quick & easy.

StringBuffer Question

P: n/a
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
Share this Question
Share on Google+
4 Replies


P: n/a
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

P: n/a


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

P: n/a
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

P: n/a

"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.