package com.test;

import java.io.FileOutputStream;
import java.io.InputStream;
import java.net.URL;
import java.net.URLConnection;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;

public class SavePic100 {

	Connection conn = null;
	PreparedStatement pre = null;
	Statement sta = null;
	ResultSet rs = null;
	static SavePic100 sp = null;

	public static void main(String[] args) {
		sp = new SavePic100();
		sp.dis_imgsrc100("test.jpg","http://img.baidu.com/img/image/liulanimage/w_meinv.jpg","d:");
	}

	public void dis_imgsrc100(String dis_img, String dis_imgsrc568, String filepath) {
		URL url;
		try {
			int bytesum = 0;
			int byteread = 0;
			url = new URL(dis_imgsrc568);
			URLConnection conn = url.openConnection();
			// 获得连接
			InputStream inStream = conn.getInputStream();
			// 生成输入流文件
			FileOutputStream fs = new FileOutputStream(filepath + dis_img);
			byte[] buffer = new byte[30000];
			while ((byteread = inStream.read(buffer)) != -1) {
				bytesum += byteread;
				// 字节数 文件大小
				System.out.println(bytesum);
				fs.write(buffer, 0, byteread);
			}
			inStream.close();
		} catch (Exception e) {
			System.out.println("保存失败");
		}
	}

	

}
最近下载更多
crosa_Don  LV18 2022年7月5日
chenxiaoqiang  LV2 2022年3月2日
438265764  LV14 2019年8月6日
skystory  LV11 2019年4月27日
xxljxgz  LV21 2018年6月9日
2856571872  LV2 2016年8月4日
ouyangyuanling  LV1 2016年5月27日
thl1229  LV15 2016年5月11日
你是我的眼  LV11 2015年6月30日
wade123  LV31 2014年10月26日
最近浏览更多
1WQAQW1  LV2 2023年6月12日
heqian  LV16 2023年1月10日
1358849392  LV21 2022年11月11日
crosa_Don  LV18 2022年7月5日
chenxiaoqiang  LV2 2022年3月2日
guaixia163  LV13 2020年6月3日
wei112233  LV15 2020年5月20日
lsq54365  LV14 2020年5月14日
lyp1314521125  LV1 2020年3月30日
dengpand  LV8 2020年3月19日
顶部 客服 微信二维码 底部
>扫描二维码关注最代码为好友扫描二维码关注最代码为好友