/*
把多个流合并一个流
*/
import java.io.*;
import java.util.*;
class
{
public static void main(String[] args)
{
Vector<FileInputStream> v = new Vector<FileInputStream>();
v.add(new FileInputStream(F:\\javatest\\1.txt));
v.add(new FileInputStream(F:\\javatest\\2.txt));
v.add(new FileInputStream(F:\\javatest\\3.txt));
Enumeration<FileInputStream> en = new v.elements();
SequenceInputStream sis = new SequenceInputStream(en);
FileOutputStream fw = new FileOutputStream(F:\\javatest\\4.txt))
byter[] arr = new byter[1024];
int len=0;
while((len=sis.read(arr))!=-1)//这句话该怎么理解,一直感觉有迷惑,
{
fos.writer(buf,0,len);
}
fos.close();
sis.close();
}
} |