This week's book giveaway is in the OCPJP forum.
We're giving away four copies of OCA/OCP Java SE 7 Programmer I & II Study Guide and have Kathy Sierra & Bert Bates on-line!
See this thread for details.
The moose likes Java in General and the fly likes Quotes in strings Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCA/OCP Java SE 7 Programmer I & II Study Guide this week in the OCPJP forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "Quotes in strings" Watch "Quotes in strings" New topic
Author

Quotes in strings

David Garratt
Ranch Hand

Joined: Aug 08, 2003
Posts: 198

I want to embed a " character in a string - I must be simple but I can't see how to do it. In VB I would probably use chr$(34).

Thanks in advance

Dave
Scott Dunbar
Ranch Hand

Joined: Sep 23, 2004
Posts: 245
Escape it:


[ October 31, 2005: Message edited by: Scott Dunbar ]

<a href="http://forums.hotjoe.com/forums/list.page" target="_blank" rel="nofollow">Java forums using Java software</a> - Come and help get them started.
vasu maj
Ranch Hand

Joined: Jul 12, 2001
Posts: 395
You can negate the special nature of the character by adding a backslash in front of it. It will be treated as a regular character and not as a quote.


What a wonderful world!
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 39478
    
  28
Look up the "escape" sequences with a \ in.
\" \' \b \n \r \t etc
David Garratt
Ranch Hand

Joined: Aug 08, 2003
Posts: 198

Thanks to you all for replying so quickly with exactly what I needed to know.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Quotes in strings