HttpClient 接口类
DefaulthttpClient --> 继承了AbstracthttpClient --> 实现了HttpClient
HttpClient get 方式提交数据
//打开浏览器
HttpClient client = new DefaultHttpClient();
//输入地址
String path = "http://www.baidu.com?username="+URLEncoder.encode(username);
HttpGet get = new HttpGet(path);
//敲回车 返回值
Httpresponse response = client.execute(httpGet);
int code = response.getStatusLine().getStatusCode();//请求返回的状态码 200成功
InputStream is = response.getEntity.getContent();
String text = StreamTools.readInputStream(is);
HttpClient post方式提交数据
//打开浏览器
HttpClient client = new DefaultHttpClient();
//输入地址
String path = "http://www.baidu.com”;
HttpPost post= new HttpGet(path);
//制定要提交的数据实体
list<NameValuePair> param = new ArrayList<NameValuePaire>():
param.add(new BasicNameValuepair("key",value);
........
param.add(new BasicNameValuepair("key",value);
post.setEntity(new UriEncodedFormEntity(param,"UTF-8");
//敲回车 返回值
Httpresponse response = client.execute(httpGet);
int code = response.getStatusLine().getStatusCode();//请求返回的状态码 200成功
InputStream is = response.getEntity.getContent();
String text = StreamTools.readInputStream(is);
a