根据地址下载文件
2023-09-14 09:00:06 时间
public static final String HTTp_URL="http:下载链接"; public static void main(String[] args) { Dol(); } public static void Dol(){ BufferedInputStream bis=null; BufferedOutputStream bos=null; try { URL url = new URL(HTTp_URL); HttpURLConnection connection = (HttpURLConnection) url.openConnection(); connection.setRequestMethod("GET"); connection.connect(); InputStream is = connection.getInputStream(); bis = new BufferedInputStream(is); File file = new File("D:/test/"+HTTp_URL.substring((HTTp_URL.lastIndexOf("/"))));//名字截取 可以省略 FileOutputStream fos = new FileOutputStream(file); bos = new BufferedOutputStream(fos); int b = 0; byte[] byArr = new byte[1024*4]; while((b=bis.read(byArr))!=-1){ bos.write(byArr, 0, b); } } catch (Exception e) { e.printStackTrace(); }finally{ try { if(bis!=null){ bis.close(); } if(bos!=null){ bos.close(); } } catch (IOException e) { e.printStackTrace(); } } } }
相关文章
- C/C++ 定位文件 .text 区段地址
- 【Android 内存优化】图片文件压缩 ( Android 原生 API 提供的图片压缩功能能 | 图片质量压缩 | 图片尺寸压缩 )
- 【Android 逆向】ELF 文件格式 ( ELF 文件类型 | ELF 文件对应 CPU 架构 | ELF 目标文件版本 | 可执行程序起始地址 )
- 基于标准的http来实现Android多文件上传详解手机开发
- java读取jar包内的文件详解编程语言
- 用dom4j解析xml文件详解编程语言
- 配置Linux IP地址文件配置指南(linuxip地址文件)
- 文件解除Linux系统中的隐藏文件束缚(linux删除隐藏)
- Linux 解压.z文件的妙招(linux.z文件解压)
- 看个视频也被黑?加载字幕文件触发播放器漏洞实现系统入侵
- 如何在 Linux 中查看文件的地址(linux查看文件地址)
- Linux命令行下的文件打包技巧(linux打包文件命令行)
- Linux大文件存储:更丰富的空间管理之选(linux大文件存储)
- 用JSP编写文件上传
- JSP点击链接后下载文件(相当于右键另存)功能
- 简单的加密css地址防止别人下载你的CSS文件的方法
- 网站下载文件时地址加jdfwkey=的说明
- C#解析Excel并且生成Csv文件代码分析