File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Ranch Office and the fly likes replace 1 char. by 2 char. in java Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


JavaRanch » Java Forums » This Site » Ranch Office
Reply Bookmark "replace 1 char. by 2 char. in java" Watch "replace 1 char. by 2 char. in java" New topic
Author

replace 1 char. by 2 char. in java

satyaonline
Greenhorn

Joined: Aug 23, 2001
Posts: 2
Dear Friends,
i want to pass '(apostrophy) character to the database hence,i use following code,
String mystr="let's find out what's going on";
char c='\'';
char c1='\\'+'\'';
mystr=mystr.replace(c,c1);
but above code had one problem since one character can be replaced by only one character,how can i replace in above ' by \' in above string.
Thanking you,
Hiteshonline.(satya)
Jim Yingst
Wanderer
Sheriff

Joined: Jan 30, 2000
Posts: 18670
This forum is intended for questions and comments about this web site, www.javaranch.com. It is not for questions about the Java language - that's what all our other forums are for. I'm moving this to "Java in General (Intermediate)", where it has a better chance of being answered.
Also, please read our user name policy and re-register with a valid name. Thank you.


"I'm not back." - Bill Harding, Twister
 
I agree. Here's the link: http://zeroturnaround.com/jrebel - it saves me about five hours per week
 
subject: replace 1 char. by 2 char. in java
 
Similar Threads
Compile time Difference between // and /* */
replace 1 char. by 2 char. in java
A question about using 'UTF8'
Java char data type problem
a quiz on character conversion to String