Is there any easiest way to replace any carriage return in a String into "<BR>" when formatting the output to HTML?
I know there is a method of String called "replaceAll" but seems only available since JDK 1.4
Derek.
Printable View
Is there any easiest way to replace any carriage return in a String into "<BR>" when formatting the output to HTML?
I know there is a method of String called "replaceAll" but seems only available since JDK 1.4
Derek.
There maybe an easier way but this'll do it just as well...
Mrs KCode:public static String replaceAll(String theString, String oldString, String newString)
{
String a;
String b;
int index = theString.indexOf(oldString);
while(index != -1)
{
a = theString.substring(0, index);
b = theString.substring(index + oldString.length());
theString = a + newString + b;
index = theString.indexOf(oldString);
}
return theString;
}
thanks a lot