这两者都可以发送消息流,URLConnection是socket的高层封装。
URLConnection使用
get>:
HttpURLConnection conn = url.openConnection();
int responseCode = conn.getResponseCode();
...
post>:
HttpURLConnection conn = url.openConnection();
conn.setRequestProperty("Content-Length",100);
...
out = conn.getOutputStream();
out.write(...);
out.flash();
int responseCode = conn.getResponseCode();
int resLen = conn.getContentlength();
in = conn.getInputStream();
...
阅读(926) | 评论(0) | 转发(0) |