URL url = new URL(urlString);
URLConnection connection = url.openConnection();
connection.setDoOutput(true);
PrintWriter out = new PrintWriter(connection.getOutputStream());
boolean first = true;
for (Map.Entry<String, String> pair : nameValuePairs.entrySet())
{
if (first) first = false;
else out.print('&');
String name = pair.getKey();
String value = pair.getValue();
System.out.println(name);
System.out.println(value);
out.print(name);
out.print('=');
out.print(URLEncoder.encode(value, "UTF-8"));
}
out.close();
本文来自CSDN博客,转载请标明出处:http://blog.csdn.net/helloxtayfnje/archive/2009/12/17/5026608.aspx