本文共 975 字,大约阅读时间需要 3 分钟。
正版疯狂java讲义第5版编程教材
80.6元
(需用券)
去购买 >
public static void main(String[] args) {
String ImageUrl = "xxxxxxxxx";//图片url
String path="F://createVerifyCode.jpg";// 保存地址
downloadPic(ImageUrl ,path);
}
//链接url下载图片
public static boolean downloadPic(String urlList,String path) {
URL url = null;
try {
url = new URL(urlList);
DataInputStream dataInputStream = new DataInputStream(url.openStream());
FileOutputStream fileOutputStream = new FileOutputStream(new File(path));
ByteArrayOutputStream output = new ByteArrayOutputStream();
byte[] buffer = new byte[1024];
int length;
while ((length = dataInputStream.read(buffer)) > 0) {
output.write(buffer, 0, length);
}
fileOutputStream.write(output.toByteArray());
dataInputStream.close();
fileOutputStream.close();
return true;
} catch (MalformedURLException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
return false;
}
原文链接:http://st4024589553.iteye.com/blog/2425548
java程序设计与数据结构(第4版)
116.1元
包邮
(需用券)
去购买 >
转载地址:https://blog.csdn.net/weixin_32946543/article/details/115782595 如侵犯您的版权,请留言回复原文章的地址,我们会给您删除此文章,给您带来不便请您谅解!