'How to replace angle brackets instead of remove using Jsoup and Whitelist in Java

This is my code

String unescapeHtml = StringEscapeUtils.unescapeHtml(item.getContent());
String cleanHtml = Jsoup.clean(unescapeHtml, Whitelist.relaxed());

item.setContent(xssUtil.removeXss(cleanHtml));

I want replace angle bracket instead of erasing them.

ex) < TEXT > -> &lt; TEXT &gt;

How can I fix it?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source