package test; import java.io.*; import java.util.Enumeration; import java.util.Vector; /** * @author shusheng * @description * @Email shusheng@yiji.com * @date 2018/12/23 15:55 */ public class SequenceInputStreamDemo2 { public static void main(String[] args) throws IOException { // SequenceInputStream(Enumeration e) // 通过简单的回顾我们知道了Enumeration 是Vector 中的一个方法的返回值类型。 // Enumeration<E> elements() Vector<InputStream> v = new Vector<InputStream>(); InputStream s1 = new FileInputStream("a.txt"); InputStream s2 = new FileInputStream("b.txt"); InputStream s3 = new FileInputStream("c.txt"); v.add(s1); v.add(s2); v.add(s3); Enumeration<InputStream> en = v.elements(); SequenceInputStream sis = new SequenceInputStream(en); BufferedOutputStream bos = new BufferedOutputStream( new FileOutputStream("d.txt")); // 如何写读写呢,其实很简单,你就按照以前怎么读写,现在还是怎么读写 byte[] bys = new byte[1024]; int len = 0; while ((len = sis.read(bys)) != -1) { bos.write(bys, 0, len); } bos.close(); sis.close(); } }