切割文件

    public static void main(String[] args) throws IOException {
        File file=new File("寸草心.mp3");
        splitFile(file);
    }
    public static void splitFile(File file) throws IOException{
            FileInputStream fis=new FileInputStream(file);
            byte[] buf=new byte[1024*1024];
            FileOutputStream fos=null;
            
            File dir=new File("c:\\artfiles");
            if(!(dir.exists()))
                    dir.mkdirs();
            int len=0;
            int count=1;
            while((len=fis.read(buf))!=-1)
            {
                fos=new FileOutputStream(new File(dir,(count++)+".part"));
                fos.write(buf,0,len);
            }
            fos.close();
            fis.close();
        }
原文地址:https://www.cnblogs.com/kedoudejingshen/p/2733591.html