Skip to Main Content

Java Programming

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

How to replace special characters by "" in Java ?

807589Jan 14 2009 — edited Jan 15 2009
Dear Java Community,

I am calling one method which pulls the String object from database. (Contents of the String object is as mentioned below, ie the email contents)
____________________________________________________
From : ABC
To : XYZ
Sent at : 01/14/2009 12:30 PM
____________________________________________________
Approved by JKL

Then using the replaceAll method, I am trying to replace "\n" and "\t" by "" but it is not working.

MyString s = "Above content";
s.replaceAll("\\n","");
s.replaceAll("\\t","");
System.out.println(s);

Can some one help me ? Do I need to use replaceAll(String regex, String replacement) ??

Thanks in Advance
Mithuan
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Feb 12 2009
Added on Jan 14 2009
6 comments
2,812 views