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) {
}
}
版权声明:本文内容来自第三方投稿或授权转载,原文地址:https://blog.51cto.com/u_13604316/2729486,作者:秦怀杂货店,版权归原作者所有。本网站转在其作品的目的在于传递更多信息,不拥有版权,亦不承担相应法律责任。如因作品内容、版权等问题需要同本网站联系,请发邮件至ctyunbbs@chinatelecom.cn沟通。