- public static void main(String[] args) throws IOException {
- File file = new File("f:\\abc.mkv");
- fileIntoPartMethod(file);
-
- }
- public static void fileIntoPartMethod(File file) throws IOException {
- FileInputStream fis = new FileInputStream(file);
- FileOutputStream fos = null;
- File dir = new File("f:\\fileParts");
- if(!dir.exists()){
- dir.mkdirs();
- }
- byte[] buf = new byte[1024*1024];
- int len = 0;
- while((len=fis.read(buf))!= -1){
- int count = 0;
- fos = new FileOutputStream(new File(dir,(count++)+".part"));
- fos.write(buf, 0, len);
- fos.flush();
-
- }
- fos.close();
- fis.close();
- }
- }
复制代码
伙伴们知道为什么我运行了之后,碎片文件夹创建起来了,但文件夹里为空的?我看了视频感觉是一样的啊??
|
|