File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
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
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: 41621
    
  55
The toString method returns a String object that represents the StringBuffer contents.


Ping & DNS - my free Android networking tools app
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!!!
 
Consider Paul's rocket mass heater.
 
subject: How to convert StringBuffer to String ?