Here you can find the source of readURLContents(String UrlText)
public static String readURLContents(String UrlText)
//package com.java2s; //License from project: Apache License import java.net.URL; import java.io.*; public class Main { public static String readURLContents(String UrlText) { try {/*from ww w . j a v a 2 s.c om*/ InputStream in = openURLStream(UrlText); String page = readStream(in); return (page); } catch (IOException ex) { throw new IllegalArgumentException(ex.toString()); // should not happen } } public static InputStream openURLStream(String in) throws IOException { URL inUrl = new URL(in); InputStream ret = inUrl.openStream(); return (ret); } public static String readStream(InputStream in) { BufferedInputStream TheStream = null; StringBuffer s = new StringBuffer(2048); try { TheStream = new BufferedInputStream(in, 2048); int c = TheStream.read(); while (c != -1) { s.append((char) c); c = TheStream.read(); // ought to look at non-printing chars } TheStream.close(); } catch (IOException e) { return (null); } return (s.toString()); } }