Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

How to convert StringBuffer to String ?  RSS feed

 
Sourav Satyajit Mishra
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello everyone,
i am facing the problem of converting a StringBuffer to String ?
how do i do it.....

Please help!!!
 
Ulf Dittmer
Rancher
Posts: 42970
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The toString method returns a String object that represents the StringBuffer contents.
 
sameer meher
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Sourav Satyajit Mishra
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks people!!!
 
Don't get me started about those stupid light bulbs.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!