81,092
社区成员
发帖
与我相关
我的任务
分享
用这个类:HttpURLConnection
URL url = new URL("yourUrl");
HttpURLConnection httpConn =(HttpURLConnection) url.openConnection();
httpConn.setRequestMethod("POST");
httpConn.setDoOutput(true);
httpConn.getOutputStream().write(("name=yourname&age=yourage").getBytes("ISO8859-1"));
httpConn.getOutputStream().flush();
httpConn.getOutputStream().close();
//以下是获得反馈
BufferedReader in = new BufferedReader(new InputStreamReader(httpConn.getInputStream()));
input = "";
while ((input = in.readLine()) != null) {
System.out.println(input);
}
in.close();
httpConn.disconnect();