Here you can find the source of readUrl(URL url, String[]... headers)
public static String readUrl(URL url, String[]... headers) throws IOException
//package com.java2s; import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.net.URL; import java.net.URLConnection; public class Main { public static String readUrl(URL url, String[]... headers) throws IOException { BufferedReader reader = null; StringBuilder buffer = new StringBuilder(); try {/*from w w w. j a v a2 s . c om*/ URLConnection connection = url.openConnection(); for (String[] header : headers) connection.addRequestProperty(header[0], header[1]); reader = new BufferedReader(new InputStreamReader( connection.getInputStream())); int read; char[] chars = new char[1024]; while ((read = reader.read(chars)) != -1) buffer.append(chars, 0, read); } finally { if (reader != null) reader.close(); } return buffer.toString(); } }