Here you can find the source of sendGet(String url, String param)
public static String sendGet(String url, String param) throws Exception
//package com.java2s; //License from project: Apache License import java.io.BufferedReader; import java.io.InputStreamReader; import java.net.HttpURLConnection; import java.net.URL; public class Main { public static String sendGet(String url, String param) throws Exception { String result = ""; BufferedReader in = null; HttpURLConnection conn = null; try {//from ww w .j a va2s . c o m String urlNameString = url + "?" + param; URL realUrl = new URL(urlNameString); conn = (HttpURLConnection) realUrl.openConnection(); conn.setConnectTimeout(10000); conn.setReadTimeout(5000); conn.setRequestProperty("accept", "*/*"); conn.setRequestProperty("connection", "Keep-Alive"); conn.setRequestProperty("user-agent", "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1;SV1)"); conn.connect(); in = new BufferedReader(new InputStreamReader(conn.getInputStream())); String line; while ((line = in.readLine()) != null) result = result + line; } catch (Exception e) { throw e; } finally { try { if (in != null) in.close(); } catch (Exception e2) { e2.printStackTrace(); } if (conn != null) { conn.disconnect(); } } return result; } }