码迷,mamicode.com
首页 > Web开发 > 详细

http 重要代码

时间:2017-03-12 23:55:17      阅读:343      评论:0      收藏:0      [点我收藏+]

标签:type   str   error   cat   ror   runtime   from   sys   connect   

 URL restServiceURL = new URL(sb.toString());// 最终url
System.out.println("finalUrl1----" + sb.toString());
HttpURLConnection httpConnection = (HttpURLConnection) restServiceURL.openConnection();
httpConnection.setRequestMethod("GET");
httpConnection.setRequestProperty("Content-Type", "application/x-www-form-urlencoded");
if (httpConnection.getResponseCode() != 200) {
throw new RuntimeException(
"HTTP GET Request Failed with Error code : " + httpConnection.getResponseCode());
}
BufferedReader responseBuffer = new BufferedReader(
new InputStreamReader((httpConnection.getInputStream())));
String output;
System.out.println("Output from Server:  \n");
while ((output = responseBuffer.readLine()) != null) {
result_count = output;
System.out.println(output);
}

http 重要代码

标签:type   str   error   cat   ror   runtime   from   sys   connect   

原文地址:http://www.cnblogs.com/yongyao/p/6539997.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!