文件的分割
来源:互联网 发布:mac的app store在哪里 编辑:程序博客网 时间:2024/05/27 19:26
需要的时候看一下就行了
public static void main(String[] args)throws IOException { //文件的分割 File file = new File("ok.jpg"); split(file); } //分割文件 public static void split(File file)throws IOException { //判断是不是文件 if(file.isDirectory()) { System.out.println("不是文件"); return; } //把切割出的文件放到同一个目录下 File dir = new File("fenge"); if(!dir.exists()) dir.mkdir(); //切割文件,每个文件的大小最大是2M //读取被切割的文件,每读够2兆就写入到一个新的文件 FileInputStream fis = new FileInputStream("ok.jpg"); FileOutputStream fos = null; byte[] arr = new byte[1024*1024*2];//2M int len = 0; int num = 0; while((len = fis.read(arr))!=-1) { fos = new FileOutputStream(new File(dir,(++num)+".kuai")); fos.write(arr,0,len); } //生成说明信息:文件类型,文件个数 Properties pro = new Properties(); pro.setProperty("fileType",file.getName()); pro.setProperty("fileNum",String.valueOf(num)); fos = new FileOutputStream(new File(dir,"readme.txt")); pro.store(fos,"分割文件信息"); fis.close(); fos.close(); }
0 0
- 文件分割的代码
- PHP 文件的分割
- 文件的分割
- 合并分割的文件
- java文件的分割
- FreamStream文件的分割
- 文件的分割
- 一个文件分割的程序
- 文件的合并与分割
- 文件的分割和合并
- 文件的合并与分割
- 文件的分割和合并
- 文件的分割与合并
- WinRAR的文件分割功能
- 文件的分割与合并
- PDF文件的分割方法
- 文件的分割与合并
- 文件的分割与合并
- laravel 表 添加注释
- Maximum traffic between city and its neighbors
- Hello World~Miracle is coming!!!
- bfs对路径有条件(必须拿到某个东西)
- 命名规范
- 文件的分割
- Android中日期选择器与时间选择器的实现
- C语言再学习 -- printf、scanf占位符
- angularjs 单选按钮 默认选中
- POJ2689——Prime Distance(大区间素数筛)
- Shortest substring containing three short strings
- 【机房收费】概况总结
- ZooKeeper实战应用之【统一配置管理】
- Lancome5_order