HttpURLConnection请求
来源:互联网 发布:淘宝女包 编辑:程序博客网 时间:2024/05/30 04:23
try { URL url = new URL("请求地址"); HttpURLConnection openConnection = (HttpURLConnection) url.openConnection(); //设置请求方式 openConnection.setRequestMethod("GET"); //得到请求码int responseCode = openConnection.getResponseCode();if (responseCode == 200) { InputStream inputStream = openConnection.getInputStream(); int len; byte[] b = new byte[1024]; ByteArrayOutputStream arrayOutputStream = new ByteArrayOutputStream(); while ((len = inputStream.read(b)) != -1) { arrayOutputStream.write(b, 0, len); }String strJson = arrayOutputStream.toString();//handler发送信息,主线程中更新数据 handler.obtainMessage(SUCCESS, strJson).sendToTarget(); }} catch (Exception e) { // TODO Auto-generated catch block e.printStackTrace();}
0 0
- HttpURLConnection请求
- HttpURLConnection请求
- HttpURLConnection请求
- HttpURLConnection 请求
- HttpUrlConnection请求
- HttpURLConnection请求服务
- HttpURLConnection post 请求
- HttpURLConnection请求图片
- HttpURLConnection post请求
- 请求网络之HttpUrlConnection
- HttpURLConnection数据请求
- HttpUrlconnection get请求数据
- Android HttpURLConnection post请求
- httpUrlConnection请求数据
- HttpURLConnection 的get请求
- HttpURLConnection请求数据
- HttpURLConnection请求网络
- HttpURLConnection请求数据
- ARM汇编 – (2) ARM程序状态寄存器
- 十、森林与并查集---(2)并查集的创建
- 个人总结 Yii 部分关键代码
- 最大熵简介
- ListView 中嵌入GridView去滚动效果
- HttpURLConnection请求
- HTML列表
- 【转】查询表结构
- ComboBox用AddString添加字符显示乱码
- 删除文件夹
- 二维数据的白化处理
- 笔记2:WebRequest 及 WebResponse 类介绍
- 安卓定位的四种介绍方式
- 士兵杀敌(二)