Here you can find the source of get(String url, Map
public static String get(String url, Map<String, String[]> params) 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; import java.util.Map; public class Main { private static final String USER_AGENT = "Mozilla/5.0"; public static String get(String url) throws Exception { return get(url, ""); }/*from w w w. j a v a 2 s. com*/ public static String get(String url, Map<String, String[]> params) throws Exception { StringBuilder sb = new StringBuilder(); if (!params.isEmpty()) { sb.append("?"); } int idx = 0; for (String column : params.keySet()) { if (idx > 0) { sb.append("&"); } ; sb.append(column); sb.append("="); sb.append(params.get(column)[0]); idx++; } return get(url, sb.toString()); } public static String get(String url, String urlParameters) throws Exception { String lUrl = url + urlParameters; // System.out.println(lUrl); URL obj = new URL(lUrl); HttpURLConnection con = (HttpURLConnection) obj.openConnection(); // optional default is GET con.setRequestMethod("GET"); //add request header con.setRequestProperty("User-Agent", USER_AGENT); // int responseCode = con.getResponseCode(); BufferedReader in = new BufferedReader(new InputStreamReader(con.getInputStream())); String inputLine; StringBuffer response = new StringBuffer(); while ((inputLine = in.readLine()) != null) { response.append(inputLine); } in.close(); return response.toString(); } }