import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.SequenceInputStream;
import java.util.Enumeration;
import java.util.Vector;
public class SequenceInputStreamDemo
{
public static void main(String[] args) throws Exception
{
//集合中只有vector中有enmereition
Vector<FileInputStream> v = new Vector<FileInputStream>();
v.add(new FileInputStream("d:\\1.txt"));
v.add(new FileInputStream("d:\\2.txt"));
v.add(new FileInputStream("d:\\3.txt"));
Enumeration<FileInputStream> en = v.elements();
SequenceInputStream sis = new SequenceInputStream(en);
FileOutputStream fos = new FileOutputStream("d:\\4.txt");
byte [] buf = new byte[1024];
int len = 0;
while( (len = sis.read()) != -1 )
{
fos.write(buf, 0, len);
}
fos.close();
sis.close();
}
}
|