aspose file tools*
The moose likes Beginning Java and the fly likes simple string replace question Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "simple string replace question" Watch "simple string replace question" New topic
Author

simple string replace question

Ravi Shankarappa
Ranch Hand

Joined: Jan 09, 2010
Posts: 55
hi,

In a string, how do I replace all occurrences of "\" by "\\" ?.

Thanks in advance.

-Ravi
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19670
    
  18

By using String.replace(CharSequence, CharSequence) - String implements CharSequence so you can use String literals. Unlike String.replaceAll, this method doesn't take regular expressions so you need a lot less escaping.


SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6
How To Ask Questions How To Answer Questions
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: simple string replace question