English Deutsch Français Italiano Español Português 繁體中文 Bahasa Indonesia Tiếng Việt ภาษาไทย
All categories

how do you delete the contents of a string buffer? i mean clean it out and erase all the previous data? the strng buffer i created, i don't know how to empty it of info. thanx

2007-03-23 03:42:52 · 5 answers · asked by Chustar Of Naija 2 in Computers & Internet Programming & Design

5 answers

use stringbuffer.delete(0,stringbuffer.length-1)
That will remove all of the charecters.

RJ

2007-03-23 03:52:47 · answer #1 · answered by Anonymous · 0 0

you can also simply do the following...

let say this is your current Stringbuffer

StringBuffer myStr = new StringBuffer( "Some texts" );
.........
//when you decide you want to empty it, simply type
myStr = new StringBuffer( );
// this will reconstruct the stringbuffer with no characters in it

2007-03-26 01:58:18 · answer #2 · answered by Liviawarty J 2 · 0 0

Use the 'delete(int start, int end)' method like such.

yourStringBuffer = yourStringBuffer.delete(0, yourStringBuffer.length());

2007-03-23 10:52:58 · answer #3 · answered by Mark aka jack573 7 · 0 0

Can't you just set it to "null"?

2007-03-23 10:50:26 · answer #4 · answered by joec_11 3 · 0 0

sb.clear();

2007-03-23 11:15:54 · answer #5 · answered by abd 5 · 0 0

fedest.com, questions and answers