if (obj instanceof String) {
try {
// first try to interpret string as URL
URL url = new URL(obj.toString());
return getHtmlDocument(new InputStreamReader(url.openStream()));
} catch (MalformedURLException nourl) {
// if not a URL, maybe it is the XML itself
return getHtmlDocument(new StringReader(obj.toString()));
}
} else if (obj instanceof InputStream) {
return getHtmlDocument(new InputStreamReader((InputStream) obj));
} else if (obj instanceof Reader) {
return getHtmlDocument((Reader) obj);
} else {
throw new RuntimeException("Unrecognized argument to parseHtml: " + obj);
}