// Using java.net.URL and //java.net.URLConnection URL url = new URL("http://jobsearch.dice.com/jobsearch/jobsearch.cgi"); URLConnection connection = url.openConnection(); 然后把连接设为输出模式。URLConnection通常作为输入来使用,比如下载一个Web页。通过把URLConnection设为输出,你可以把数据向你个Web页传送。下面是如何做:
... OutputStreamWriter out = new OutputStreamWriter(UC.getOutputStream(), "8859_1"); out.write("username=bob&passWord="+password+""); // remember to clean up out.flush(); out.close(); 这样就可以发送一个看起来象这样的POST: