Is there a recommended way to escape <, >, \" and & characters when outputting HTML in plain Java code? (Other
<
>
\"
&
For those who use Google Guava:
import com.google.common.html.HtmlEscapers; [...] String source = "The less than sign (<) and ampersand (&) must be escaped before using them in HTML"; String escaped = HtmlEscapers.htmlEscaper().escape(source);