保存网络图片
public String saveImage(String destUrl) {
FileOutputStream fos = null;
BufferedInputStream bis = null;
HttpURLConnection httpUrl = null;
URL url;
try {
url = new URL(destUrl);
httpUrl = (HttpURLConnection) url.openConnection();
httpUrl.connect();
bis = new BufferedInputStream(httpUrl.getInputStream());
return qiniuService.uploadByStream(bis);//七牛中通过流上传
} catch (IOException | ClassCastException e) {
e.printStackTrace();
} finally {
try {
if (fos != null) {
fos.close();
}
if (bis != null) {
bis.close();
}
if (httpUrl != null) {
httpUrl.disconnect();
}
} catch (IOException | NullPointerException e) {
e.printStackTrace();
}
}
return null;
}