This question was asked once already, but the API changed I guess and the answers are no valid anymore.
URL url = new URL(\"http://www.example.com\");
String
Using HTMLUnit 2.40, Grooveek's code won't compile, you get "Cannot make a static reference to the non-static method parseHtml(WebResponse, WebWindow) from the type HTMLParser". But there is now a class HtmlUnitNekoHtmlParser implementing the HTMLParser interface, so the following code works:
StringWebResponse response = new StringWebResponse(
"Test ",
new URL("http://www.example.com"));
HtmlPage page = new HtmlUnitNekoHtmlParser().parseHtml(
response, new WebClient().getCurrentWindow());