URL url
=
new
URL(
"
.......
"
);
HttpURLConnection con = (HttpURLConnection) url.openConnection();
con.setDoOutput( true ); // POST方式
con.setRequestMethod( " POST " );
OutputStream os = con.getOutputStream(); // 输出流,写数据
os.write( " .......... " .getBytes());
BufferedReader reader = new BufferedReader( new InputStreamReader(con.getInputStream())); // 读取结果
String line;
while ((line = reader.readLine()) != null ) ... {
System.out.println(line);
}
HttpURLConnection con = (HttpURLConnection) url.openConnection();
con.setDoOutput( true ); // POST方式
con.setRequestMethod( " POST " );
OutputStream os = con.getOutputStream(); // 输出流,写数据
os.write( " .......... " .getBytes());
BufferedReader reader = new BufferedReader( new InputStreamReader(con.getInputStream())); // 读取结果
String line;
while ((line = reader.readLine()) != null ) ... {
System.out.println(line);
}