文件合并流的基本用法 – 恵玩科技

package IO.com.lxgyx_06;

import java.io.*;

public class SequenceInputSreamDemo {
    public static void main(String[] args) throws IOException {
        InputStream is1=new FileInputStream("test\\pw.txt");
        InputStream is2=new FileInputStream("test\\pw2.txt");

        SequenceInputStream sis=new SequenceInputStream(is1,is2);
        BufferedOutputStream bos=new BufferedOutputStream(new FileOutputStream("test\\pw3.java"));

        byte[] bys=new byte[1024];
        int len=0;
        while ((len=sis.read(bys))!=-1){
            bos.write(bys,0,len);
        }

        bos.close();
        sis.close();
    }
}

 

打赏作者