android http get
2016-02-02 11:12
323 查看
private class goDb implements View.OnClickListener { @Override public void onClick(View v) { new AsyncTask<String,Void,Void>(){ @Override protected Void doInBackground(String... params) { try { URL url = new URL(params[0]); try { HttpURLConnection connection = (HttpURLConnection) url.openConnection(); InputStream is = connection.getInputStream(); InputStreamReader isr = new InputStreamReader(is, "utf-8"); BufferedReader br = new BufferedReader(isr); String line; while ((line = br.readLine()) != null) { System.out.println(line); } br.close(); isr.close(); is.close(); } catch (IOException e) { e.printStackTrace(); } } catch (MalformedURLException e) { e.printStackTrace(); } return null; } }.execute("http://fanyi.youdao.com/openapi.do?keyfrom=testwtw&key=1422432408&type=data&doctype=json&version=1.1&q=good"); } }
相关文章推荐
- TCP协议发送和接受文本消息
- centos 开启httpd service 出现ServerName error
- virtualbox 0x80004005 网络错误解决办法
- 中软国际首届嘉年华晚会 创新网络年会PK“春晚”
- Java 网络编程
- iOS 数据库离线缓存思路和网络层封装
- HTTP协议详解
- hdu 3081(并查集+最大流)
- Error:Unable to tunnel through proxy. Proxyreturns "HTTP/1.1 400 Bad Request"
- 巧用LoRa无线网络 远距离采集温湿度
- 封装原生ajax
- http://www.oschina.net/code/snippet_2507499_53892
- HTTP协议头部与Keep-Alive模式详解
- Http 请求中Content -Type 讲解以及在Spring MVC 中的应用
- OK335xS 网络连接打印信息 hacking
- 第五章 采用SVM和神经网络的车牌识别
- IOS-网络(NSURLSession)
- Android OkHttp完全解析 是时候来了解OkHttp了
- HTTP状态码
- 基于libsmart的网络编程示例之EchoServer