Here you can find the source of getUrlContents(URL url)
public static String getUrlContents(URL url) throws IOException
//package com.java2s; //License from project: Apache License import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.net.URL; public class Main { public static String getUrlContents(URL url) throws IOException { BufferedReader bReader = null; String contents = null;/*from w ww . ja v a 2 s. co m*/ try { StringBuilder buf = new StringBuilder(); bReader = new BufferedReader(new InputStreamReader(url.openStream())); String inputLine; while ((inputLine = bReader.readLine()) != null) { buf.append(inputLine); } contents = buf.toString(); } finally { if (bReader != null) bReader.close(); } return contents; } }