文件分割器,一个读取流,相应多个输出流,并且生成的碎片文件都有有序的编号
2023-09-27 14:27:00 时间
import java.io.File; import java.io.FileInputStream; import java.io.FileNotFoundException; import java.io.FileOutputStream; import java.io.IOException; import java.util.Properties; public class FileSpilte { /** * @param args * @throws IOException */ /* * 文件分割器, * 一个读取流,相应多个输出流。并且生成的碎片文件都有有序的编号 */ public static void main(String[] args) throws IOException { File destdir = new File("teampFile\\filepart"); File file = new File("E:\\A-Lin - 给我一个理由忘记.mp3"); fileSplite(file,destdir); } private static void fileSplite(File file, File destdir) throws IOException { if(!file.exists()){ throw new RuntimeException(destdir+"文件不存在"); } if(!destdir.exists()) { destdir.mkdirs(); } FileInputStream fis = new FileInputStream(file); FileOutputStream fos = null; byte[] buf =new byte[1024*1024]; int count = 0; int len = 0; while((len=fis.read(buf))!=-1){ File partfile = new File(destdir,(++count)+".part"); fos = new FileOutputStream(partfile); fos.write(buf,0,len); fos.close(); } Properties prop =new Properties(); prop.setProperty("partcount",Integer.toString(count)); prop.setProperty("filename", file.getName()); File profile = new File(destdir,(++count)+".properties"); fos=new FileOutputStream(profile); prop.store(fos, "save"); fos.close(); } }
相关文章
- 【C++】继承/多态/文件
- CS0016: 未能写入输出文件“c:WINDOWSMicrosoft.NETFramework.。。”--“拒绝访问
- IIS发布网站 检测到在集成的托管管道模式下不适用的 ASP.NET 设置。未能写入输出文件“c:WindowsMicrosoft.NETFramework ...拒绝访问
- spring +log4j 配置日志按天,小时滚动输出切成文件
- springboot 整合logback实现日志出入到不同文件当中(含sql输出到制定文件中)
- 应用程序启动器 “sublime_text.desktop“ 还没有被标记为 信任。如果您不知道这个文件的来源,那么启动它可能会不安全。解决sublime在ubuntu中不支持中文输入问题。
- 转:MVC2表单验证失败后,直接返回View,已填写的内容就会清空,可以这样做;MVC2输出文本;MVC2输出PDF文件
- git批量恢复所有删除的文件
- linux挂载光盘和文件
- letex编辑输出】pdf文件嵌入字体embedded fonts的问题
- 看我如何利用文件扩展名绕过AppLocker?
- PADS VX2.7学习记录05-PADS Layout设计文件Gerber等输出整理
- 在Python中使用moviepy进行视频剪辑时输出文件报错 'NoneType' object has no attribute 'stdout'问题
- PS CC 2014 把一个图层输出为文件的方法
- Android中关于JNI 的学习(五)在C文件里使用LogCat
- php实现简单的文件上传和验证
- java递归实现文件夹文件的遍历输出
- 错误 1 error C1083: 无法打开包括文件: “numpy/arrayobject.h”: No such file
- 在日志文件中输出当前时间
- go 输出日志文件 loghelp :goland 输出日志文件 进阶版(1)
- lightdb wal文件误删恢复及归档wal清理
- java最简单复制文件方法,不依赖任何框架
- 2019-8-31-dotnet-通过-HttpClient-下载文件同时报告进度的方法
- 2019-4-29-Roslyn-将这个文件放在你的项目文件夹,无论哪个控制台项目都会输出林德熙是逗比...
- 打包iso文件的话,怎样使用hybrid格式输出?isohybrid:command not found
- Python + logging 输出到屏幕,将log日志写入文件
- 如何将终端输出的信息重定向写入文件中呢?
- golang学习之gin(四):参数绑定、文件上传、其他数据格式输出、自定义HTTP配置