I have a PageRead class and methods which will download the html source code from a given url.
public class PageRead {
public static StringBuilder readPage(String pageAddr) {
try {
URL url = new URL(pageAddr);
BufferedReader reader = new BufferedReader(new
InputStreamReader(url.openStream()));
String line;
StringBuilder sb=new StringBuilder();
while ((line = reader.readLine()) != null) {
sb.append(line+"\n");
}
reader.close();
return sb;
}
catch (MalformedURLException e) {
e.printStackTrace();
return new StringBuilder("");
}
catch (IOException e) {
e.printStackTrace();
return new StringBuilder("");
}
}
public static void main(String arg[]){
System.out.println(readPage("http://www.google.com"));
}
}
This will return me the source code in a String soemthing like :
<!doctype html>.......</body></html>
Is there a way to display this html in something like a JFrame using this source code?