package test; import java.io.File; import java.io.FileInputStream; import java.io.FileOutputStream; import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; import java.io.SequenceInputStream; public class Test { public static void main(String[] args) throws IOException { InputStream in1=new FileInputStream("d:"+File.separator+"a.txt"); InputStream in2=new FileInputStream("d:"+File.separator+"b.txt"); OutputStream out=new FileOutputStream("d:"+File.separator+"ab.txt"); SequenceInputStream in=new SequenceInputStream(in1,in2); int temp=0; while((temp=in.read())!=-1){ out.write(temp); } in1.close(); in2.close(); in.close(); out.close(); } /** * 輸出 */ }