小白想请教下各位大神,使用HttpUplConnnection时需要用到IO流对数据进行读取,然而使用HttpClient时却不需要用到。。例如:
try {
HttpClient httpClient = new DefaultHttpClient();//获取实例
HttpGet httpGet = new HttpGet(address[0]);//创建HttpGet对象,传入网络地址
HttpResponse httpResponse = httpClient.execute(httpGet);//IOException
if (httpResponse.getStatusLine().getStatusCode() == 200){
HttpEntity httpEntity = httpResponse.getEntity();//获取HttpEntity实例
result = EntityUtils.toString(httpEntity,"utf-8");//转换为字符串
return result;
}
} catch (IOException e) {
e.printStackTrace();
}
是不是里面哪里封装了对IO的操作,使我们不用像HttpUplConnnection那样对使用IO。。。。另外想问下,使用HttpClient的过程中,会抛出什么其它的异常?
多谢各位解答下小白的疑问!