/**
* Given some html, extracts its text.
*/
public static String extractTextFromHTML(String html) {
try {
EditorKit kit = new HTMLEditorKit();
Document doc = kit.createDefaultDocument();
// The Document class does not yet handle charset's properly.
doc.putProperty("IgnoreCharsetDirective", Boolean.TRUE);
// Create a reader on the HTML content.
Reader rd = new StringReader(html);
// Parse the HTML.
kit.read(rd, doc, 0);
// The HTML text is now stored in the document
return doc.getText(0, doc.getLength());
} catch (Exception e) {
}