Here you can find the source of httpGet(String httpUrl)
public static String httpGet(String httpUrl)
//package com.java2s; //License from project: Apache License import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.net.HttpURLConnection; import java.net.MalformedURLException; import java.net.URL; public class Main { public static String httpGet(String httpUrl) { BufferedReader input = null; StringBuilder sb = null;/* www . j a v a 2s. c o m*/ URL url = null; HttpURLConnection con = null; try { url = new URL(httpUrl); try { con = (HttpURLConnection) url.openConnection(); input = new BufferedReader(new InputStreamReader(con.getInputStream())); sb = new StringBuilder(); String s; while ((s = input.readLine()) != null) { sb.append(s).append("\n"); } } catch (IOException e) { e.printStackTrace(); } } catch (MalformedURLException e1) { e1.printStackTrace(); } finally { // close buffered if (input != null) { try { input.close(); } catch (IOException e) { e.printStackTrace(); } } // disconnecting releases the resources held by a connection so they may be closed or reused if (con != null) { con.disconnect(); } } return sb == null ? null : sb.toString(); } }