参数path包括 文件名
public static void downloadFile(String _url,String path) {
URL url = null;
try {
url = new URL(_url);
URLConnection conn = url.openConnection();
conn.setConnectTimeout(5*1000);
InputStream is = conn.getInputStream();
byte[] bs = new byte[1024];
int length;
OutputStream os = new FileOutputStream(path);
while((length=is.read(bs))!=-1) {
os.write(bs,0,length);
}
os.close();
is.close();
} catch (MalformedURLException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
}