public class StringEscapeUtils
extends java.lang.Object
| Modifier and Type | Class and Description |
|---|---|
static class |
StringEscapeUtils.Entities
Provides HTML and XML entity utilities.
|
| Constructor and Description |
|---|
StringEscapeUtils() |
| Modifier and Type | Method and Description |
|---|---|
static java.lang.String |
escapeHtml(java.lang.String str)
Escapes the characters in a
String using HTML entities. |
static void |
escapeHtml(java.io.Writer writer,
java.lang.String string)
Escapes the characters in a
String using HTML entities and writes them to a Writer. |
public static java.lang.String escapeHtml(java.lang.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(java.io.Writer writer,
java.lang.String string)
throws java.io.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 nulljava.lang.IllegalArgumentException - if the writer is nulljava.io.IOException - 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 © 2022. All Rights Reserved.