public static void download(String _url,String path) throws Exception{
try{
URL url = new URL(_url);
URLConnection con = url.openConnection();
con.setConnectTimeout(5000);
InputStream is = con.getInputStream();
byte[] bs = new byte[1024];
int len;
File sf=new File(path);
OutputStream os = new FileOutputStream(sf);
while ((len = is.read(bs)) != -1) {
os.write(bs, 0, len);
}
os.close();
is.close();
} catch (IOException e) {
}
}
如果有所帮助,脸皮厚求个赞~
此文章仅代表自己(本菜鸟)学习积累记录,或者学习笔记,如有侵权,请联系作者删除。人无完人,文章也一样,文笔稚嫩,在下不才,勿喷,如果有错误之处,还望指出,感激不尽~
技术之路不在一时,山高水长,纵使缓慢,驰而不息。
公众号:秦怀杂货店