Java Swing HTML htmlToPlain(String html)

Here you can find the source of htmlToPlain(String html)

Description

html To Plain

License

Open Source License

Declaration

public static String htmlToPlain(String html) 

Method Source Code

//package com.java2s;
//License from project: Open Source License 

import javax.swing.text.Document;

import javax.swing.text.html.HTMLEditorKit;

import java.io.*;

public class Main {
    public static String htmlToPlain(String html) {
        HTMLEditorKit htmlParser = new HTMLEditorKit();
        Document document = htmlParser.createDefaultDocument();
        try {//from  ww w  . jav a 2 s.  c om
            htmlParser.read(new ByteArrayInputStream(html.getBytes()), document, 0);
            String plain = document.getText(0, document.getLength());
            return plain;
        } catch (Exception e) {
            throw new RuntimeException("Error converting HTML to plain text", e);
        }
    }
}

Related

  1. findLinkUp(Element elem)
  2. getHTMLFromXML(String xml, URL xsl)
  3. getImgs(final String html)
  4. getRowIndex(final Element cell)
  5. hasClass(AttributeSet attr, String className)
  6. isUnderline(Element element)
  7. loadStyleSheet(URL url)
  8. makeStyleSheet(String name)
  9. nameOf(Element element)