This week's giveaway is in the EJB and other Java EE Technologies forum.
We're giving away four copies of EJB 3 in Action and have Debu Panda, Reza Rahman, Ryan Cuprak, and Michael Remijan on-line!
See this thread for details.
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 EJB 3 in Action this week in the EJB and other Java EE Technologies 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: 39541
    
  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
a simple question
Converting from a String to a StringBuffer
regarding strings
Difference between String and StringBuffer.
Pls HELP! How to count the number of row in file?