Java下载网络文件

/ 原创 / 没有评论 / 631浏览
@SneakyThrows
    private void doDown(String url, String path) {
        BufferedInputStream in = new BufferedInputStream(new URL(url).openStream());
        File file = new File(path);
        FileOutputStream out = new FileOutputStream(file);
        IOUtils.copy(in, out);
        in.close();
        out.close();
    }