Java可以使用URL类和URLConnection类来下载文件到指定目录。代码示例如下:

try {
    URL url= new URL("http://example.com/example.zip");
    URLConnection conn = url.openConnection();
    InputStream in = conn.getInputStream();
    FileOutputStream out = new FileOutputStream("C:\\example.zip");
    byte[] b = new byte[1024
Logo

技术共进,成长同行——讯飞AI开发者社区

更多推荐