zoukankan      html  css  js  c++  java
  • 合并分割后的文件

        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();
        }
  • 相关阅读:
    第二章例2-9
    第二章例2-8
    第二章例2-7
    第二章例2-6
    第二章例2-5
    第二章例2-4
    第二章例2-3
    第二章例2-2
    第二章例2-1
    第一章例1-2
  • 原文地址:https://www.cnblogs.com/kedoudejingshen/p/2733779.html
Copyright © 2011-2022 走看看