After scrounging Google (It was hard to get good search terms) I made this which appears to work fine:
Code:package com.turtletips; import java.net.URL; import java.io.IOException; import java.io.InputStream; import java.io.BufferedReader; public class HTMLDownloader { public static String getHTMLFromURL(URL u) throws Exception { try { StringBuffer cache = new StringBuffer(); InputStream in = u.openStream(); int currentByte = in.read(); while (currentByte != -1) { cache.append((char)currentByte); currentByte = in.read(); } return new String(cache); } catch (Exception e) { throw e; } } public static void main(String[] args) { try { System.out.println(HTMLDownloader.getHTMLFromURL( new URL("http://www.sunspot.net/wireless/avantgo/"))); } catch (Exception e) { e.printStackTrace(); } } }




Reply With Quote