HttpClient发送Get请求(java)【从新浪云搬运】
2016-03-30 21:02
621 查看
直接上代码吧
public static void sendHttpGet(final String url){ //发送Get请求的方法,url中已经带了需要的参数。 new Thread(new Runnable() { @Override public void run() { HttpGet getMethod = new HttpGet(url); HttpClient httpClient = new DefaultHttpClient(); try { HttpResponse response = httpClient.execute(getMethod); //发起GET请求 Log.i("HTQ", "resCode = " + response.getStatusLine() .getStatusCode()); //获取响应码 Log.i("HTQ", "result = " + EntityUtils .toString(response.getEntity(), "utf-8"));//获取服务器响应内容 } catch (Exception e){ e.printStackTrace(); } } }).start(); }
相关文章推荐
- dreamweaver测试服务器的站点URL前缀与在HTTP地址中为该站点指定的站点URL前缀不匹配
- BP神经网络与RBF神经网络讲得好的博客链接
- delphi 使用superobject实现jsonrpc的http远程调用 good
- HTTP状态码
- (4.6.5)移动端网络优化
- TCP协议三次握手与四次挥手详解
- TCP协议三次握手与四次挥手详解
- TCP
- android用okhttp和retrofit访问网络的时候有时候出现EOFException异常
- 实例说明TCP和UDP有什么区别
- 【Android】Android客户端使用okhttp上传文件php服务器
- java-入门:模拟网络购物支付系统
- ASP.NET网络编程学习第一步:清晰概念
- 在android中使用HttpURLConnection进行文件上传
- 《神经网络与深度学习》的教学方法
- 常用的http请求header
- http协议通信过程和请求格式
- 网络40ms延迟问题
- springMVC:org.springframework.web.servlet.PageNotFound.handleHttpRequestMethodNotSupported Request method 'POST' not supported
- Swift 2.0 异步网络请求从网页获取json,并转化为NSArray,遍历得到其中数据.