Android通过GET方式访问网络页面
来源:互联网 发布:网络矩阵价格 编辑:程序博客网 时间:2024/05/17 04:12
因为只是GET方式访问,所以跟Post相比少了很多设置的内容。
下面是访问网络的函数封装(代码实现的是通过访问网络词典查询某一单词):
package com.jesusjzp.connet;import java.io.BufferedReader;import java.io.IOException;import java.io.InputStreamReader;import java.net.HttpURLConnection;import java.net.MalformedURLException;import java.net.URL;import android.util.Log;public class GetData {public String getConnect(String word) {String res = "";String httpUrl = "http://www.frdic.com/dict/bon/SearchDic.aspx?word=bon";Log.v("httpUrl:", httpUrl);URL url = null;try {url = new URL(httpUrl);} catch (MalformedURLException e) {Log.e("GetData.java", "MalformedURLException");}if(url != null) {try {HttpURLConnection urlConn = (HttpURLConnection) url.openConnection();urlConn.connect();BufferedReader reader = new BufferedReader(new InputStreamReader(urlConn.getInputStream()));String inputLine = null;while (((inputLine = reader.readLine()) != null)) {res += inputLine + "\n";}reader.close();urlConn.disconnect();} catch (IOException e){Log.e("GetData.java", "IOException");}}return res;}}
最终返回的res将是整个页面的HTML页面信息。
- Android通过GET方式访问网络页面
- Android通过GET和POST方式访问WCF服务(Json)
- Android通过get,post方式体访问http服务器
- Android 通过get和post方法访问网络
- JAVA通过HTTP访问:Post+Get方式
- JAVA通过HTTP访问:Post+Get方式
- python网络爬虫学习(一)通过GET和POST方式获取页面内容
- android访问网络方式
- Android Get方式网络请求
- android网络请求get方式
- 通过Post方式访问Web页面
- android通过网络访问adb
- Android 网络通信之通过GET和POST方式提交参数给web应用
- Android:网络:通过GET和POST两种方式上传参数
- android开发 使用HttpClient访问网络,post、get方式。注册、登陆、上传文件。
- android中HTTP协议访问网络及其方式及其http的GET和POST的优缺点
- 安卓网络编程-通过GET方式获取网络图片
- Android网络访问请求方式
- prefabs
- 二叉树的非递归遍历
- Oracle与Access在开发中的不同之处
- Mahout推荐算法中的其他数据结构
- android dialog 的item项点击
- Android通过GET方式访问网络页面
- JAVA的IO流学习中(1)
- hdu 2152 母函数
- 【OSC手机App技术解析】- 用户通知
- 有关脱壳以及脱壳实例讲解
- 计算网站有效PV注意事项
- 生成JNI的DLL时提示找不到jni.h的解决办法(fatal error C1083: Cannot open include file: 'jni.h':).
- javascript 字符串函数 以及 字符串转别的类型
- Java 构造函数能被继承吗