-
什么是序列流
-
序列流可以把多个字节输入流整合成一个,从序列流中读取数据时,将从被整合的第一个流开始读,读完一个之后继续读第二个, 以此类推.
-
-
-
- 整合两个的实例:
- SequenceInputStream(InputStream, InputStream)
-
View Code
package com.heima.otherio; import java.io.FileInputStream; import java.io.FileOutputStream; import java.io.FileWriter; import java.io.IOException; import java.io.SequenceInputStream; public class Demo1_SequenceInputStream { /** * @param args * @throws IOException */ public static void main(String[] args) throws IOException { FileInputStream fis1 = new FileInputStream("a.txt"); FileInputStream fis2 = new FileInputStream("b.txt"); SequenceInputStream sis = new SequenceInputStream(fis1, fis2); FileOutputStream fos = new FileOutputStream("out.txt"); int b; while((b = sis.read()) != -1) { fos.write(b); } sis.close(); fos.close(); } }
相关文章: