*
The moose likes Java in General and the fly likes How to convert  StringBuffer to String ? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Java 8 in Action this week in the Java 8 forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "How to convert  StringBuffer to String ?" Watch "How to convert  StringBuffer to String ?" New topic
Author

How to convert StringBuffer to String ?

Sourav Satyajit Mishra
Greenhorn

Joined: May 08, 2008
Posts: 10
Hello everyone,
i am facing the problem of converting a StringBuffer to String ?
how do i do it.....

Please help!!!


----------------------------------<br />You may only be a person in this world, but for someone, you�re the world.
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 39576
    
  27
The toString method returns a String object that represents the StringBuffer contents.


Ping & DNS - updated with new look and Ping home screen widget
sameer meher
Greenhorn

Joined: Jun 06, 2008
Posts: 10
Try the following code:

StringBuffer sbuf = new StringBuffer("sameer");
String str = sbuf.toString();
System.out.println(str);

toString() will convert from StringBuffer to String object


Regards,<br />Sameer
Sourav Satyajit Mishra
Greenhorn

Joined: May 08, 2008
Posts: 10
Thanks people!!!
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: How to convert StringBuffer to String ?
 
Similar Threads
Difference between String and StringBuffer.
regarding strings
Converting from a String to a StringBuffer
a simple question
Pls HELP! How to count the number of row in file?