如何在Java中下载大文件(大小> 50MB)

如何在Java中下载大文件(大小> 50MB),第1张

如何在Java中下载大文件(大小> 50MB)

您可以使用apache commons IO库。这很容易。我已经在许多项目中使用过它。

File dstFile = null;// check the directory for existence.String dstFolder = LOCAL_FILE.substring(0,LOCAL_FILE.lastIndexOf(File.separator));if(!(dstFolder.endsWith(File.separator) || dstFolder.endsWith("/")))    dstFolder += File.separator;// Creates the destination folder if doesn't not existsdstFile = new File(dstFolder);if (!dstFile.exists()) {    dstFile.mkdirs();}try {    URL url = new URL(URL_LOCATION);    FileUtils.copyURLToFile(url, dstFile);} catch (Exception e) {    System.err.println(e);    VeBLogger.getInstance().log( e.getMessage());}


欢迎分享,转载请注明来源:内存溢出

原文地址: https://outofmemory.cn/zaji/5616150.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-12-15
下一篇 2022-12-15

发表评论

登录后才能评论

评论列表(0条)

保存