1

Possible Duplicate:
How would you convert a String to a Java string literal?

Is there a library function that takes a string and converts is into a corresponding string literal? Example:

Please say\ask "What?" three times! -> "Please say\\ask \"What?\" three times!"

Community
  • 1
  • 1
fredoverflow
  • 256,549
  • 94
  • 388
  • 662

1 Answers1

7

I think commons lang StringUtils does that

http://commons.apache.org/proper/commons-lang/apidocs/org/apache/commons/lang3/StringEscapeUtils.html

166_MMX
  • 590
  • 5
  • 18
Prasanna Talakanti
  • 2,354
  • 1
  • 16
  • 16