public class sequenceInputStreamDemo {
@Test
public void t1() throws IOException{
List<FileInputStream> list=new ArrayList<FileInputStream>();//写一个list放FileInputStream
list.add(new FileInputStream("file/sqe/1.txt"));
list.add(new FileInputStream("file/sqe/2.txt"));
list.add(new FileInputStream("file/sqe/3.txt"));
Enumeration<FileInputStream> en = Collections.enumeration(list);//※将list转换成枚举
//入口
SequenceInputStream sis = new SequenceInputStream(en);//※放入序列zhong
//流拷贝
//把序列流中的数据写到一个文件中
FileOutputStream fout = new FileOutputStream("file/sqe/a.txt");
byte b[] = new byte[8];
int len = 0;
while( (len=sis.read(b))!=-1){
fout.write(b, 0, len);
}
fout.close();
sis.close();
}
@Test
public void t1() throws IOException{
List<FileInputStream> list=new ArrayList<FileInputStream>();//写一个list放FileInputStream
list.add(new FileInputStream("file/sqe/1.txt"));
list.add(new FileInputStream("file/sqe/2.txt"));
list.add(new FileInputStream("file/sqe/3.txt"));
Enumeration<FileInputStream> en = Collections.enumeration(list);//※将list转换成枚举
//入口
SequenceInputStream sis = new SequenceInputStream(en);//※放入序列zhong
//流拷贝
//把序列流中的数据写到一个文件中
FileOutputStream fout = new FileOutputStream("file/sqe/a.txt");
byte b[] = new byte[8];
int len = 0;
while( (len=sis.read(b))!=-1){
fout.write(b, 0, len);
}
fout.close();
sis.close();
}