src/main/java/me/codeboy/common/base/net/core/CBConnection.java
public void saveToFile(File file)
            throws IOException {
        if (CBStringUtil.isEmptyOrNull(this.url)) {
            return;
        }
        URL url = new URL(this.url);
        URLConnection conn = url.openConnection();
        InputStream is = conn.getInputStream();
        OutputStream os = new FileOutputStream(file);
        byte[] b = new byte[1024];
        int len;
        while ((len = is.read(b)) != -1) {
            os.write(b, 0, len);
        }
        os.close();
        is.close();
    }
public void saveToFile(File file)
            throws IOException {
        if (CBStringUtil.isEmptyOrNull(this.url)) {
            return;
        }
        URL url = new URL(this.url);
        URLConnection conn = url.openConnection();
        InputStream is = conn.getInputStream();
        OutputStream os = new FileOutputStream(file);
        byte[] b = new byte[1024];
        int len;
        while ((len = is.read(b)) != -1) {
            os.write(b, 0, len);
        }
        os.close();
        is.close();
    }
保存指定位置的文件

@param file 保存文件
@throws IOException IO异常