首页>代码>jsoup简单的图片抓取demo>/ImageSpider/src/com/csu/test/Util.java
package com.csu.test;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.net.URL;

public class Util {

	/**
	 * @author CSU-Max
	 * @param strUrl	图片的路径
	 * @param path		保存的路径	
	 * @throws IOException
	 */
	public void download(String strUrl, String path) throws IOException {

		URL url = null;
		InputStream is = null;
		OutputStream os = null;
		byte[] buffer = new byte[8192];
		int bytesRead = 0;
		
		try {
			
			url = new URL(strUrl);
			is = url.openStream();
			os = new FileOutputStream(path);
			
			while ((bytesRead = is.read(buffer, 0, 8192)) != -1) {
				
					os.write(buffer, 0, bytesRead);
					
				}
			} catch (IOException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}finally{
				
				is.close();
				os.close();
				
			}
	}
}
最近下载更多
zhangguobin  LV14 2019年9月10日
1662530129  LV12 2019年8月12日
yihang  LV7 2019年2月3日
dagf113225  LV68 2019年1月9日
756398953  LV12 2018年11月15日
冬瓜Summit  LV10 2018年6月11日
360763120  LV11 2018年4月27日
lindawhn  LV6 2018年4月12日
xl921005  LV1 2017年6月16日
yly123  LV17 2017年3月29日
最近浏览更多
好的好的  LV8 2022年7月7日
qiaofu22  LV4 2022年6月3日
mySong  LV11 2022年3月3日
心印语  LV9 2022年3月3日
tdcq123  LV14 2022年1月18日
微笑刺客  LV15 2021年12月30日
Yangwanyun  LV4 2021年7月29日
wwwwwhx  LV10 2020年9月10日
lzxzuidaima  LV5 2020年5月7日
IraqiHa  LV6 2020年5月1日
顶部 客服 微信二维码 底部
>扫描二维码关注最代码为好友扫描二维码关注最代码为好友