cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

convert StringBuffer to String[]

Former Member
0 Likes
1,952

how to convert StringBuffer to String Array ?


StringBuffer strContent=new StringBuffer();
for(int i=0;i<3;i++){
strContent.append("This is new message:" +i);
}

//how to add to this
String[] strArrContent = {};

View Entire Topic
Former Member
0 Likes

Hi Yzme,

we can differentiate between String and String buffer like , A string buffer is similar to String, but the contents can be modified at any point of time using some methods.

To convert a String buffer into a String we have toString() method.

for example :

x = "a" + 4 + "c"

is similar to

x = new StringBuffer().append("a").append(4).append("c")

.toString()

where x is a string..

reference :

<a href="http://java.sun.com/j2se/1.4.2/docs/api/">http://java.sun.com/j2se/1.4.2/docs/api/</a>

Do reward points..if this helps u in reaching at ur solution;

//

how to convert StringBuffer to String Array ?

StringBuffer strContent=new StringBuffer();

for(int i=0;i<3;i++){

strContent.append("This is new message:" +i);

}

//how to add to this

String[] strArrContent = {};