String unescapedText = "This & That < Here > There"; String escapedText = StringUtil.escapeXml(unescapedText); System.out.println(escapedText); // prints: "This & That < Here > There"
String unescapedText = "This is a paragraph with a bold tag.
"; String escapedText = StringUtil.escapeXml(unescapedText); System.out.println(escapedText); // prints: "<p>This is a paragraph with a <b>bold</b> tag.</p>"
String unescapedText = "This ☕️ is a coffee cup."; String escapedText = StringUtil.escapeXml(unescapedText); System.out.println(escapedText); // prints: "This ☕️ is a coffee cup."The StringUtil class is part of the IntelliJ IDEA SDK and is contained in the package com.intellij.openapi.util.text.