Here you can find the source of getHTTPResponse(String url)
public static String getHTTPResponse(String url) throws IOException
//package com.java2s; /**/*from w w w . j a v a2 s . co m*/ * Helix * Copyright (c) Matheus Vigaro <matheus@vigaro.tk>, All rights reserved. * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 3.0 of the License, or (at your option) any later version. * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * You should have received a copy of the GNU Lesser General Public * License along with this library. **/ import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.net.HttpURLConnection; import java.net.URL; import java.util.zip.GZIPInputStream; public class Main { public static String getHTTPResponse(String url) throws IOException { HttpURLConnection con = (HttpURLConnection) (new URL(url)) .openConnection(); BufferedReader reader = new BufferedReader( new InputStreamReader("gzip".equals(con .getContentEncoding()) ? new GZIPInputStream( con.getInputStream()) : con.getInputStream())); StringBuilder response = new StringBuilder(); String l; while ((l = reader.readLine()) != null) { response.append(l); response.append('\r'); } reader.close(); return response.toString(); } }