Here you can find the source of readUrl(final String url)
public static String readUrl(final String url)
//package com.java2s; import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.net.MalformedURLException; import java.net.URL; import java.net.URLConnection; public class Main { public static String readUrl(final String url) { try {//from www .j a v a 2 s . c om return readUrl(new URL(url)); } catch (MalformedURLException e) { throw new RuntimeException("Can't get url from string " + url); } } public static String readUrl(final URL url) { StringBuffer resultData = new StringBuffer(); BufferedReader in = null; try { URLConnection urlConnection = url.openConnection(); in = new BufferedReader(new InputStreamReader(urlConnection.getInputStream())); String inputLine; while ((inputLine = in.readLine()) != null) resultData.append(inputLine); } catch (Exception e) { throw new RuntimeException("Can't read data from url " + url, e); } finally { if (in != null) { try { in.close(); } catch (IOException e) { // ignore } } } return resultData.toString(); } }