呼叫网址
//from n o w j a v a . c o m //package com.nowjava; import java.io.BufferedReader; import java.io.InputStreamReader; import java.io.OutputStreamWriter; import java.net.URL; import java.net.URLConnection; import java.net.URLEncoder; import java.util.Map; public class Main { public static String callUrl(String urlString,/*from nowjava - 时代Java*/ Map<String, String> paramMap) { String urlReturnValue = ""; try { // Construct data StringBuffer dataBuf = new StringBuffer(); boolean firstParam = true; for (String paramKey : paramMap.keySet()) { if (!firstParam) dataBuf.append("&"); dataBuf.append(URLEncoder.encode(paramKey, "UTF-8")) .append("=") .append(URLEncoder.encode(paramMap.get(paramKey), "UTF-8")); firstParam = false; } String data = dataBuf.toString(); // Send data URL url = new URL(urlString); URLConnection conn = url.openConnection(); conn.setDoOutput(true); OutputStreamWriter wr = new OutputStreamWriter( conn.getOutputStream()); wr.write(data); wr.flush(); // Get the response BufferedReader rd = new BufferedReader(new InputStreamReader( conn.getInputStream())); String l