public static String test(String URL, List<BasicNameValuePair> params) {HttpPost httpPost = new HttpPost(URL);String returnString = "";HttpParams httpParameters = new BasicHttpParams();try {UrlEncodedFormEntity urlEncodedFormEntity = new UrlEncodedFormEntity(params, "utf-8");httpPost.setEntity(urlEncodedFormEntity);HttpConnectionParams.setConnectionTimeout(httpParameters, 3000);HttpClient httpClient = new DefaultHttpClient(httpParameters);HttpResponse httpResponse = httpClient.execute(httpPost);HttpEntity httpEntity = httpResponse.getEntity();InputStream inputStream = httpEntity.getContent();BufferedInputStream bufferedInputStream = new BufferedInputStream(inputStream);ByteArrayBuffer byteArrayBuffer = new ByteArrayBuffer(50);int current = 0;while ((current = bufferedInputStream.read()) != -1) {byteArrayBuffer.append(current);}returnString = EncodingUtils.getString(byteArrayBuffer.toByteArray(), "utf-8");} catch (UnsupportedEncodingException e) {e.printStackTrace();} catch (ClientProtocolException e) {e.printStackTrace();} catch (IOException e) {e.printStackTrace();}return returnString;}

更多相关文章

  1. 代码中设置drawableleft
  2. android 3.0 隐藏 系统标题栏
  3. Android开发中activity切换动画的实现
  4. Android(安卓)学习 笔记_05. 文件下载
  5. Android中直播视频技术探究之—摄像头Camera视频源数据采集解析
  6. 技术博客汇总
  7. android 2.3 wifi (一)
  8. AndRoid Notification的清空和修改
  9. Android中的Chronometer

随机推荐

  1. Android利用Ksoap2连接webservice 源码
  2. Android(安卓)Sample NotePad学习二
  3. ubuntu 搭建android编译环境
  4. Android——Activity生命周期
  5. Android(安卓)GPS获得经纬度并得到该坐标
  6. Android(安卓)http POST
  7. Android(安卓)- 保持在底部的按钮栏,上面
  8. android EditText 监听
  9. android如何获取后台正在运行的service
  10. android > 获取 通讯录 信息