public class StringEscapeUtils extends Object
| Constructor and Description |
|---|
StringEscapeUtils() |
| Modifier and Type | Method and Description |
|---|---|
static String |
escapeHtml(String str)
Escapes the characters in a
String using HTML entities. |
static void |
escapeHtml(Writer writer,
String string)
Escapes the characters in a
String using HTML entities and writes them to a Writer. |
public static String escapeHtml(String str)
Escapes the characters in a String using HTML entities.
For example:
"bread" & "butter"
"bread" & "butter" .
Supports all known HTML 4.0 entities, including funky accents. Note that the commonly used apostrophe escape character (') is not a legal entity and so is not supported).
str - the String to escape, may be nullString, null if null string input#unescapeHtml(String),
ISO Entities,
HTML 3.2 Character Entities for ISO Latin-1,
HTML 4.0 Character entity references,
HTML 4.01 Character References,
HTML 4.01 Code positionspublic static void escapeHtml(Writer writer, String string) throws IOException
Escapes the characters in a String using HTML entities and writes them to a Writer.
For example:
"bread" & "butter"
becomes:
"bread" & "butter" .
Supports all known HTML 4.0 entities, including funky accents. Note that the commonly used apostrophe escape character (') is not a legal entity and so is not supported).
writer - the writer receiving the escaped string, not nullstring - the String to escape, may be nullIllegalArgumentException - if the writer is nullIOException - when Writer passed throws the exception from calls to the
Writer.write(int) methods.escapeHtml(String),
#unescapeHtml(String),
ISO Entities,
HTML 3.2 Character Entities for ISO Latin-1,
HTML 4.0 Character entity references,
HTML 4.01 Character References,
HTML 4.01 Code positionsCopyright © 2017. All Rights Reserved.