File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

String literals

 
Andrea Hampton
Greenhorn
Posts: 2
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I can't remember how I get this to print:
<xml>MyXML</xml>
I have a StringBuffer that just says:
str.append ('<xml>MyXML</xml>');
I get an unclosed character literal error, because of the backslash. How do I get the backslash to print?
 
Dave Vick
Ranch Hand
Posts: 3244
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Andrea
Its not the forward slash that is giving you the error, it is the way you are defining the String. It should be enclosed in double quotes " when you use single quotes the compiler thinks it is a char and not a String. If you just enclose it in double quotes it'll compile fine and you wont have to escape anything.
hope that helps
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic