Skip to Main Content

New to Java

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!

Interested in getting your voice heard by members of the Developer Marketing team at Oracle? Check out this post for AppDev or this post for AI focus group information.

How to replace single backslash(\) to double backslash(\\)

838492Feb 16 2011 — edited Feb 17 2011
Hi
I want to replace single backslash to double backslash from the string.
Code is here
-----
String data="File name :\n.txt;File name:\t.txt";
data = data.replace("\\","\\\\");
System.out.println("-->" +data);
----------
i tried to this code but its not working. Help me if anyone is know.

Please reply me asap.

Thanks

Comments

Locked Post
New comments cannot be posted to this locked post.

Post Details

Locked on Mar 17 2011
Added on Feb 16 2011
13 comments
5,175 views