- 浏览: 380280 次
- 性别:
- 来自: 四川
-
文章分类
- 全部博客 (247)
- 数据库以及sql (11)
- java (48)
- 爬虫学习 (20)
- java编程 (28)
- python编程以及安装和配置 (27)
- oracle数据库 (32)
- mongodb基本操作 (4)
- linux学习 (7)
- easyUI (2)
- nodeJs (8)
- python学习 (16)
- 其他 (13)
- hadoop (1)
- svn (1)
- 汉字 (1)
- windows (2)
- jsp (5)
- fiddler (1)
- ETL (1)
- teamviewer (1)
- maven (4)
- GIT (2)
- datagrip (1)
- ocr (1)
- redis (3)
- mysql (3)
- linux (1)
- 数据服务 (0)
最新评论
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;
}
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;
}
发表评论
-
是什么java多态
2018-11-14 13:43 750Java多态 例1.1+1=2 例2."1&quo ... -
经纬度转换
2018-09-25 13:57 0package com.teamdev.jxbrowser.c ... -
java连接池技术
2018-09-04 14:26 416转:https://www.cnblogs.com/xdp-g ... -
java 提取url字符串中的域名
2018-08-30 15:24 7436package com.teamdev.jxbrowser.c ... -
java多线程中锁(lock)、wait、notify()的使用
2018-07-13 11:31 5800package com.kai.多线程间的通信; impor ... -
java多线程间的通信实例
2018-07-13 11:00 1462----线程间的通信 public class ListAd ... -
volatile关键字
2018-07-12 11:20 680volatile:使变量在多个线程间可见 public c ... -
java根据百度url获取真正的网页地址
2018-07-09 11:26 1140/** * 根据百度url,获取原本url * @th ... -
java中的base64字符流与图片的相互转换
2018-06-29 13:27 1306//base64字符串转化成图片 public sta ... -
java去除图片水印的解决办法
2018-06-28 10:54 3416原文地址:http://www.oicqzone.com/pc ... -
java中的中文字符转URLEncode
2018-06-26 11:26 833String urlTypeName =java.net.UR ... -
Myeclipse中如何更改jsp默认的打开方式
2018-05-04 17:44 6921.打开myeclipse 2.点击上方的 window-&g ... -
java三大范式
2018-05-02 09:50 794参考地址:https://www.cnblogs.com/ja ... -
请求中设置代理IP
2018-04-18 16:24 1030(不能直接JVM设置代理 System.getProperti ... -
java获取当前时间的时间戳
2018-04-08 09:25 1537package com.teamdev.jxbrowser.c ... -
java四种线程池实例 (kaigege)
2018-03-28 11:03 751Java通过Executors提供四种线程池: 1.newCa ... -
java获取IP地址(windos,linux)皆可
2018-03-28 09:44 875package com.teamdev.jxbrowser.c ... -
post 请求
2018-02-05 16:32 563public static void trustEveryo ... -
java robot控制鼠标和键盘(笔记本中打印 i love you)(滑动)
2018-01-25 16:57 2144package robot_java; import jav ... -
java ascii转中文(ascii转utf-8)清测好用
2018-01-24 17:41 3085package com.teamdev.jxbrowser.c ...
评论