序列流

来源:互联网 发布:广州市淘宝培训学校 编辑:程序博客网 时间:2024/05/21 19:46
package com.huyd.day20;


import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.SequenceInputStream;
import java.util.Vector;


public class SequenceDemo {

public static void main(String[] args) {
Vector<FileInputStream> v=new  Vector<FileInputStream>();
try {
v.add(new FileInputStream("1.txt"));
v.add(new FileInputStream("2.txt"));
v.add(new FileInputStream("3.txt"));
} catch (IOException e) {
e.printStackTrace();
}


SequenceInputStream sis=new SequenceInputStream(v.elements());

try {
FileOutputStream fo=new FileOutputStream("4.txt");
try {
int i=0;
while((i=sis.read())!=-1){
fo.write(i);
}
} catch (IOException e) {
e.printStackTrace();
}
} catch (FileNotFoundException e) {
e.printStackTrace();
}
}


}
0 0
原创粉丝点击