合并分割后的文件

    public static void main(String[] args) throws IOException {
        
        File dir=new File("c:\\artfiles");
        mergeFile(dir);
    }
    public static void mergeFile(File dir) throws IOException
    {
        ArrayList<FileInputStream> al=new ArrayList<FileInputStream>();
        
        for(int x=1;x<=5;x++){
            al.add(new FileInputStream(new File(dir,x+".part")));
        }
        Enumeration<FileInputStream> en=Collections.enumeration(al);
        SequenceInputStream sis= new SequenceInputStream(en);
        
        FileOutputStream fos=new FileOutputStream(new File(dir,"mp3.mp3"));
        byte[] buf=new byte[1024];
        int len=0;
        while((len=sis.read(buf))!=-1)
        {
            fos.write(buf,0,len);
        }
        fos.close();
        sis.close();
    }
原文地址:https://www.cnblogs.com/kedoudejingshen/p/2733779.html