java保存网络图片
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; }
相关推荐
-
java生成验证码 java
2019-1-8
-
Excel 工具类 备选 java
2019-1-13
-
使用poi将excel转换为html,适用本身有导出excel的而现在需要添加网页打印的功能 java
2019-1-8
-
JSON工具类 java
2019-1-12
-
基于redis实现的分布式锁 java
2019-1-8
-
java缓冲队列 java
2019-1-8
-
java实现文件的压缩和解压 java
2019-1-8
-
基于apache-commons-email1.4 邮件发送 java
2019-1-8
-
动态线程池管理器 java
2019-1-7
-
quartz 通用的多线程定时任务 java
2019-1-7