首页| JavaScript| HTML/CSS| Matlab| PHP| Python| Java| C/C++/VC++| C#| ASP| 其他|
购买积分 购买会员 激活码充值

您现在的位置是:虫虫源码 > Java > Android 创建HttpPost对象 获取HTTP连接

Android 创建HttpPost对象 获取HTTP连接

  • 资源大小:13.66 kB
  • 上传时间:2021-06-30
  • 下载次数:0次
  • 浏览次数:0次
  • 资源积分:1积分
  • 标      签: Android

资 源 简 介

HttpGet httpGetRequest = new HttpGet(urlGet);//创建HttpPost对象   try {    HttpResponse httpResponse = new DefaultHttpClient().execute(httpGetRequest);    if(httpResponse.getStatusLine().getStatusCode()==200){//连接成功    String result = EntityUtils.toString(httpResponse.getEntity());//获得资源    result = result.replaceAll(" | | | ", "");//去掉信息中的回车和换行    EditText etGet = (EditText)findViewById(R.id.etGet);//获得EditText对象    etGet.setText(result);//为EditText设置内容    }   } catch (Exception e) {//捕获并打印异常    EditText etGet = (EditText)findViewById(R.id.etGet);//获得EditText对象    etGet.setText("连接出错:"+e.getMessage());//为EditText设置出错信息   }

文 件 列 表

codesc.net
Sample_10_3
.project
Sample_10_3
Sample_10_3
.classpath
codesc.net
VIP VIP
0.247530s