Android25图灵聊天项目------HttpURLConnection请求get文本数据
2015-06-06 09:11
771 查看
String APIKEY = "开发者注册帐号,激活之后即可获得"; String INFO = URLEncoder.encode("北京今日天气", "utf-8"); String getURL = "http://www.tuling123.com/openapi/api?key=" + APIKEY + "&info=" + INFO; URL getUrl = new URL(getURL); HttpURLConnection connection = (HttpURLConnection) getUrl.openConnection(); connection.connect(); // 取得输入流,并使用Reader读取 BufferedReader reader = new BufferedReader(new InputStreamReader( connection.getInputStream(), "utf-8")); StringBuffer sb = new StringBuffer(); String line = ""; while ((line = reader.readLine()) != null) { sb.append(line); } reader.close(); // 断开连接 connection.disconnect(); System.out.println(sb);
源码下载:
http://download.csdn.net/detail/zhaihaohao1/8777931
相关文章推荐
- 计算机网络概述
- 生产网络架构改造遇到问题综述
- 伪造成长计划之二
- 在android用Get方式发送http请求
- 学习笔记:MFC实现http协议传输图片和文本
- linux centos 安装httpd-2.4.12
- TCP/UDP使用总结
- CetnOS minimal 网络不可用
- 微商才是世界上最花心的“男人”
- Android下网络请求的两个封装类
- ASP.NET HttpModule URL 重写 (一) 【Z】
- 计算机网络学习(6)
- 计算机网络的协议是什么
- [Servlet]深入研究HttpServlet
- [Servlet]深入研究HttpServlet
- Facebook网络模拟测试工具ATC使用
- [Servlet]Servlet的生命周期
- [Python] 网络爬虫和正则表达式学习总结
- TCP的.cc文件代码解释(中文)
- TCP的.cc文件代码解释(中文)