Im coding in Java ..
Does anyone know how I can get the contents of javax.swing.text.html.HTMLDocument as strings? This is what I got so far ...
URL url = new URL( "http://www.test.com" ); HTMLEditorKit kit = new HTMLEditorKit(); HTMLDocument doc = (HTMLDocument) kit.createDefaultDocument(); doc.putProperty("IgnoreCharsetDirective", Boolean.TRUE); Reader HTMLReader = new InputStreamReader(url.openConnection().getInputStream()); kit.read(HTMLReader, doc, 0);
I need the contents of an HTMLDocument as a String.
Example:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"> <html><head><meta http-equiv="X-UA-Compatible" content="IE=Edge,chrome=1">
....... etc.
Any help would be greatly appreciated. I need to use the HTMLDocument class to handle html correctly :)
Thanks Daniel
source share