"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