Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

ASCII Characters in Java

Posted on 2001-06-09
7
Medium Priority
?
979 Views
Last Modified: 2008-03-17
I have a function that does a find a replace routine on a given string. ie.

replace(String Input, String Find, String Replace)

Therefore, I want to insert the double quote " symbol as the Find parameter in the Replace function and replace it with a "%" symbol. The only way I can think of solving this problem is sending in a ASCII Charater as the Find String. But how do I do this. Need code examples.


0
Comment
Question by:7of9121098
  • 5
  • 2
7 Comments
 
LVL 92

Accepted Solution

by:
objects earned 200 total points
ID: 6172761
Use "\"".
replace(input, "\"", "%");

0
 

Author Comment

by:7of9121098
ID: 6172793
objects, can you please explain what the \" means, I'm new to Java, but it worked. Is there a reference web sited I can look at that explains this technique? I assume it means its a double quote...etc. Thanks.
0
 
LVL 92

Expert Comment

by:objects
ID: 6172802
The back slash sort of says to ignore any special meaning for the next character, and to treat it purely as an ASCII character.
If I can think of a reference I'll forward it on to u.
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 92

Expert Comment

by:objects
ID: 6172806
Oops, ignore my previous definition it's only partly correct. I forgot about special escape sequences such as \t \n etc.
Have a look at the following articales which includes discussions of escape sequences:
http://www.javaworld.com/javaworld/jw-12-2000/jw-1201-java101_p.html

And I'll leave the explanations to the experts and go back to just writing code :-)

0
 

Author Comment

by:7of9121098
ID: 6172811
Cool, thanks excellant explaination, you earned your cookies this week. Many thanks....
0
 
LVL 92

Expert Comment

by:objects
ID: 6172824
Mmmmm, cookies :)
0
 
LVL 92

Expert Comment

by:objects
ID: 6780578
:-)

Mick Barry
Brainbench MVP for Java 1
http://www.brainbench.com

http://www.objects.com.au
0

Featured Post

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This was posted to the Netbeans forum a Feb, 2010 and I also sent it to Verisign. Who didn't help much in my struggles to get my application signed. ------------------------- Start The idea here is to target your cell phones with the correct…
Java Flight Recorder and Java Mission Control together create a complete tool chain to continuously collect low level and detailed runtime information enabling after-the-fact incident analysis. Java Flight Recorder is a profiling and event collectio…
The viewer will learn how to implement Singleton Design Pattern in Java.
This tutorial will introduce the viewer to VisualVM for the Java platform application. This video explains an example program and covers the Overview, Monitor, and Heap Dump tabs.
Suggested Courses

916 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question