fis.write(buf,0,len)处总报错 ,实在看不出来求助!- package com.io.study.file;
- /**
- * 文件切割
- */
- import java.io.*;
- import java.util.*;
- public class SplitFile {
- public static void main(String[] args) throws IOException{
- splitFile();
- }
- public static void splitFile()throws IOException{
- FileInputStream fis=new FileInputStream("c:\\DJ.mp3");
- FileOutputStream fos=null;
- byte[]buf=new byte[1024];
-
- int len=0;
- int count=1;
- int num=0;
- File file=new File("c:\\splitfiles");
- file.mkdir();
- fos=new FileOutputStream("c:\\splitfiles\\"+count+".mp3");
- count++;
- while((len=fis.read(buf))!=-1){
- num++;
- if(num%1024==0){
- fos=new FileOutputStream("c:\\splitfiles\\" +
- (count++)+".mp3");}
- //System.out.println(num);
- fos.write(buf,0,len);
- fos.close();
- }
- fis.close();
- }
- }
复制代码
|
|