Class HtmlUtil

java.lang.Object
com.sure.tool.util.HtmlUtil

public class HtmlUtil extends Object
HTML 工具类:转义/反转义、去标签、文本清洗,零依赖。
Since:
0.2.0
Author:
suretool
  • Method Details

    • escape

      public static String escape(String html)
      HTML 转义(& < > " ')。
      Parameters:
      html - 原文
      Returns:
      转义后文本;null 返回 null
    • unescape

      public static String unescape(String text)
      HTML 反转义(& < > " '   等)。
      Parameters:
      text - 转义后文本
      Returns:
      原文;null 返回 null
    • cleanHtmlTag

      public static String cleanHtmlTag(String html)
      去除 HTML 标签(保留文本内容)。
      Parameters:
      html - 原始 HTML
      Returns:
      纯文本;null 返回 null
    • removeTag

      public static String removeTag(String html, String tag)
      去除指定标签(保留其他标签)。
      Parameters:
      html - 原始 HTML
      tag - 标签名(不含尖括号,如 "script")
      Returns:
      清洗后文本