public void downloadFile(String url, String saveAddress) { try { URL fileUrl = new URL(url); InputStream is = fileUrl.openStream(); OutputStream os = new FileOutputStream(saveAddress); byte bf[] = new byte[1024]; int length = 0; while ((length = is.read(bf, 0, 1024)) != -1) { os.write(bf, 0, length); } is.close(); os.close(); } catch (Exception e) { logger.error(e.toString()); } }
java 根据URL下载文件并保存到本地指定位置
最新推荐文章于 2024-06-22 17:10:11 发布