public static Bitmap getImage(String address) throws Exception {
Bitmap imgmap = null;
InputStream is = null;
URL url = new URL(address);
HttpURLConnection conn = (HttpURLConnection)url.openConnection();
try {
conn.setRequestMethod("GET"); >>> here was been excuted,but go to finally block
conn.setConnectTimeout(5000);
is = conn.getInputStream();
byte[] imgbytes = StreamTool.getBytes(is);
imgmap = BitmapFactory.decodeByteArray(imgbytes, 0, imgbytes.length);
} finally {
if (is != null) {
is.close();
}
if (conn != null) {
conn.disconnect();
}
}
return imgmap;
}
之前conn.setRequestMethod("GET")
被执行,throws 异常连接已经建立。谁能给我一个解决方案