public class StringEscapeUtils extends Object
Unescapes escaped chars in strings.
| Modifier and Type | Method and Description |
|---|---|
static String |
escapeJava(String input)
Escapes the characters in a
String using Java String rules. |
static String |
unescapeJava(String input)
Unescapes any Java literals found in the
String. |
public static String escapeJava(String input)
Escapes the characters in a String using Java String rules.
Deals correctly with quotes and control-chars (tab, backslash, cr, ff, etc.)
So a tab becomes the characters '\\' and
't'.
The only difference between Java strings and JavaScript strings is that in JavaScript, a single quote and forward-slash (/) are escaped.
Example:
input string: He didn't say, "Stop!" output string: He didn't say, \"Stop!\"
input - String to escape values in, may be nullnull if null string inputpublic static String unescapeJava(String input)
Unescapes any Java literals found in the String.
For example, it will turn a sequence of '\' and
'n' into a newline character, unless the '\'
is preceded by another '\'.
input - the String to unescape, may be nullString, null if null string inputCopyright © 2007–2019. All rights reserved.