private static String encodeHTMLEntities ( String string ) { if ( string == null ) { return null ; } try { return URLEncoder . encode ( string , Charset . defaultCharset ( ) . displayName ( ) ) ; } catch ( UnsupportedEncodingException exception ) { return string ; } }
Replace the special characters by HTML entities .