标签:close amd 合并 class 创建 byte 输入流 输入 throws
合并流/顺序流(sequenceInputStream):
就是把多个输入流,合并成一个流对象。
1 public class SequenceInputStreamDemo {
2 public static void main(String[] args) throws Exception {
3 //创建顺序流对象
4 SequenceInputStream in = new SequenceInputStream(new FileInputStream("stream.txt"),
5 new FileInputStream("stream2.txt"));
6
7 byte[] buffer = new byte[1024];
8 int len = -1;
9 while ((len = in.read(buffer)) != -1){
10 System.out.println(new String(buffer,0,len));
11 }
12 in.close();
13 }
14 }
标签:close amd 合并 class 创建 byte 输入流 输入 throws
原文地址:http://www.cnblogs.com/wenxudong/p/6896016.html