虽然没有错不报错,但是却抓不到数据,同时异常里可以捕抓到IO异常,但是没有提示
@Override
protected Bitmap doInBackground(String... params) {
String url=params[0];
Bitmap bitmap=null;
URLConnection connection;
InputStream is;
//通过URL.openConnection方法获得一个URLConnection对象
try {
URL myurl = new URL(url);
connection=myurl.openConnection();
connection.connect();
is=connection.getInputStream();
//包装一下
//BufferedInputStream bis=new BufferedInputStream(is);
//将一个输入流解析为一个BitMap对象
bitmap=BitmapFactory.decodeStream(is);
//关闭输入流
is.close();
//bis.close();
} catch (MalformedURLException e) {
Log.i("info", "MalformedURLException");
e.printStackTrace();
} catch (IOException e) {
Log.i("info", "IOException:"+e.toString());
e.printStackTrace();
}
return bitmap;
}
private String URL = "http://image.sinajs.cn/newchart/monthly/n/sh601003.gif";
刚刚调试获得一个异常
IOException:java.net.UnknownHostException: Unable to resolve host "image.sinajs.cn": No address associated with hostname