Here you can find the source of httpGet(String urlStr)
public static String httpGet(String urlStr) throws IOException
//package com.java2s; //License from project: Open Source License import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.net.HttpURLConnection; import java.net.URL; public class Main { public static String httpGet(String urlStr) throws IOException { URL url = new URL(urlStr); HttpURLConnection conn = (HttpURLConnection) url.openConnection(); if (conn.getResponseCode() != 200) throw new IOException(conn.getResponseMessage()); BufferedReader rd = new BufferedReader(new InputStreamReader(conn.getInputStream())); StringBuilder sb = new StringBuilder(); String line;/*from ww w . j a v a 2 s . c om*/ while ((line = rd.readLine()) != null) sb.append(line); rd.close(); conn.disconnect(); return sb.toString(); } }