十年网站开发经验 + 多家企业客户 + 靠谱的建站团队
量身定制 + 运营维护+专业推广+无忧售后,网站问题一站解决
String httpUrl = "http://api.hcl100.com/index.php/Applist/search/paging/0";
/* 建立HTTP Get对象 */
HttpGet httpRequest = new HttpGet(httpUrl);
try {
/* 发送请求并等待响应 */
HttpResponse httpResponse = new DefaultHttpClient().execute(httpRequest);
/* 若状态码为200 ok */
if (httpResponse.getStatusLine().getStatusCode() == 200) {
/* 读 */
String strResult = EntityUtils.toString(httpResponse
.getEntity());
/* 去没有用的字符 */
System.out.println(strResult);
} else {
System.out.println("123123");
}
} catch (ClientProtocolException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
} catch (Exception e) {
e.printStackTrace();
}
网站建设哪家好,找创新互联!专注于网页设计、网站建设、微信开发、成都小程序开发、集团企业网站建设等服务项目。为回馈新老客户创新互联还提供了察哈尔右翼后免费建站欢迎大家使用!
出现new DefaultHttpClient().execute(httpRequest)空的话 另开线程解决