Http请求获取返回值
HttpResponse response = client.execute(httpPost); //获取响应码 status = response.getStatusLine().getStatusCode(); HttpEntity httpEntity = response.getEntity(); //将H中返回实体转化为输入流 InputStream is = httpEntity.getContent(); //读取输入流,即返回文本内容 StringBuffer sb = new StringBuffer(); BufferedReader br = new BufferedReader(new InputStreamReader(is)); String line = ""; while((line=br.readLine())!=null){ sb.append(line); } Log.v("result", "status = " + status); Log.v("result", "sb = " + sb);
本文出自 “爬过山见过海” 博客,请务必保留此出处http://670176656.blog.51cto.com/4500575/1632360
郑重声明:本站内容如果来自互联网及其他传播媒体,其版权均属原媒体及文章作者所有。转载目的在于传递更多信息及用于网络分享,并不代表本站赞同其观点和对其真实性负责,也不构成任何其他建议。