Here you can find the source of httpGet(String url, StringBuffer response)
public static int httpGet(String url, StringBuffer response) 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 int httpGet(String url, StringBuffer response) throws IOException { URL obj = new URL(url); HttpURLConnection con = (HttpURLConnection) obj.openConnection(); //add request header con.setRequestMethod("GET"); int responseCode = con.getResponseCode(); //Debug.out.info("Response Code: "+responseCode); if (response != null && responseCode == 200 /*OK*/) { try (BufferedReader in = new BufferedReader(new InputStreamReader(con.getInputStream()))) { String inputLine; while ((inputLine = in.readLine()) != null) { response.append(inputLine); }// w ww. ja v a2s. co m } } con.disconnect(); //Logger.DebugTN("Response Data: "+response.toString()); return responseCode; } }