File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Java in General and the fly likes Adding Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "Adding " in String Variables..." Watch "Adding " in String Variables..." New topic
Author

Adding " in String Variables...

Somnath Mallick
Ranch Hand

Joined: Mar 04, 2009
Posts: 477
Hi Everyone,

I have a string which contains the character ". The problem is anywhere the " comes in the code takes it as a termination of the String and the rest of the string is ignored and hence its causing an error! For example i have to put this value in a string:

<td >CP Name</td>

The " characters are causing a problem!
Somnath Mallick
Ranch Hand

Joined: Mar 04, 2009
Posts: 477
Somehow the text after td isnt coming in the post well just wanted to let you know that after the "td" there is:
Maneesh Godbole
Saloon Keeper

Joined: Jul 26, 2007
Posts: 10167
    
    8

You need to use escape characters


[How to ask questions] [Donate a pint, save a life!] [Onff-turn it on!]
Suhas Bilaye
Ranch Hand

Joined: Sep 10, 2009
Posts: 80
Hi Somnath,

From the core java side when we want " character in a string we can do it as follows using the escape character.

String s = "\"Hello\" said Nina".
System.out.println(s);

The output will be -------"Hello" said Nina


Thanks and Regards,
Suhas
http://www.xplore-java.blogspot.com/
Maneesh Godbole
Saloon Keeper

Joined: Jul 26, 2007
Posts: 10167
    
    8

Suhas,
Please go easy on the color as it makes the text harder to read.
Somnath Mallick
Ranch Hand

Joined: Mar 04, 2009
Posts: 477
Thanks for the reply.
Suhas Bilaye
Ranch Hand

Joined: Sep 10, 2009
Posts: 80
Ok sure.. i will keep the color black itself
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Adding " in String Variables...
 
Similar Threads
Special characters parsing in Java
text field validation
display in two seprate table
JavaScript problem with IE
problem laying out element of ordered list with logic iterate