This week's book giveaway is in the General Computing forum.
We're giving away four copies of Arduino in Action and have Martin Evans, Joshua Noble, and Jordan Hochenbaum on-line!
See this thread for details.
The moose likes Beginning Java and the fly likes Cast from StringBuffer to String Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


JavaRanch » Java Forums » Java » Beginning Java
Reply Bookmark "Cast from StringBuffer to String" Watch "Cast from StringBuffer to String" New topic
Author

Cast from StringBuffer to String

Reggie McDougal
Ranch Hand

Joined: Sep 27, 2004
Posts: 69
How do I cast a stringBuffer to a string?




Is the is right way to go?

Matt


You can never drink too much
Andrew Eccleston
Ranch Hand

Joined: Jul 07, 2004
Posts: 140
You will want to use the append() method of StringBuffer when adding to string data in a StringBuffer object. Then, call StringBuffer's toString() method to return the entire contents as a string value.



To be honest, the biggest thing you can do to help yourself out, is to familiarize yourself with the api documentation at http://java.sun.com/j2se/1.5.0/docs/api/. The StringBuffer class is in the java.lang package (on the left side).

andrew

[ December 02, 2004: Message edited by: Andrew Eccleston ]
[ December 02, 2004: Message edited by: Andrew Eccleston ]

The statement below is true.<br />-------------------------------<br />The statement above is false.
 
I agree. Here's the link: http://zeroturnaround.com/jrebel - it saves me about five hours per week
 
subject: Cast from StringBuffer to String
 
Similar Threads
Stack Help...
Changing the WORLD by writing CODE
string equals question
String manipulation
String explanation