// Using java.net.URL and
//java.net.URLConnection
URL url = new
URL("http://www.126.com/index_t.htm");
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: