public static void main(String[] args) throws IOException {
//把字节输入流添加进一个Vector集合
Vector<FileInputStream> v=new Vector<FileInputStream>();
v.add(new FileInputStream("1.txt"));
v.add(new FileInputStream("2.txt"));
v.add(new FileInputStream("3.txt"));
//通过vector的elements方法,获得枚举,构造一个序列流
Enumeration<FileInputStream> en=v.elements();
SequenceInputStream sis=new SequenceInputStream(en);
//把序列流写进输出流
FileOutputStream fos=new FileOutputStream("f:\\4.txt");
byte[] buf=new byte[1024];
int len=0;
while ((len=sis.read())!=-1) {
fos.write(buf, 0, len);
}
sis.close();
fos.close();
}
得到的4.txt文件中怎么没有内容呢?
|