This discussion is archived
2 Replies Latest reply: Apr 25, 2013 12:04 AM by 1000092 RSS

How To Convert StringBuffer to String

1000092 Newbie
Currently Being Moderated
hi i want to convert the StringBuffer in to String
i have used this code but geives compile error.

import java.io.*;
import java.util.*;
import javax.mail.*;
import java.sql.*;
public class REPLACE {
static StringBuffer s= new StringBuffer("ABCD");
public static void main(String args[]) throws Exception
{
String host = "EGH";
String user = "HIJ";
String rep = "abs";
System.out.println(host);
user = host.replace("'"," ");
System.out.println(user);
System.out.println(s);
rep = s.to_String();
System.out.println(rep);
}
}

C:\jdk1.6.0_04\bin>javac REPLACE.java
REPLACE.java:15: cannot find symbol
symbol : method to_String()
location: class java.lang.StringBuffer
rep = s.to_String();
^
1 error


Please Help to Resolve

Thanks in Advance

Legend

  • Correct Answers - 10 points
  • Helpful Answers - 5 points