Here you can find the source of removeAllHtmlTags(String unsafe)
Parameter | Description |
---|---|
unsafe | unsafe |
public static String removeAllHtmlTags(String unsafe)
//package com.java2s; //License from project: Apache License import org.jsoup.Jsoup; import org.jsoup.nodes.Document; import org.jsoup.safety.Cleaner; import org.jsoup.safety.Whitelist; public class Main { /**/*from ww w . j a v a 2 s. com*/ * Remove all HTML tags from the given string * * @param unsafe unsafe * @return sanitized string */ public static String removeAllHtmlTags(String unsafe) { if (unsafe == null) { return null; } else { // Based on Jsoup.clean; the only difference is text() instead of html() Document dirty = Jsoup.parseBodyFragment(unsafe); Cleaner cleaner = new Cleaner(Whitelist.none()); Document clean = cleaner.clean(dirty); return clean.body().text(); } } }