public class SequenceInputStreamJava {
public static void main(String[] args) throws IOException {
// TODO Auto-generated method stub
String sPath1 = "d:" + File.separator + "javatest" + File.separator + "CollectionTest1.java";
String sPath2 = "d:" + File.separator + "javatest" + File.separator + "CollectionTest2.java";
Vector<FileInputStream> v = new Vector<>();
v.add(new FileInputStream(sPath1));
v.add(new FileInputStream(sPath2));
Enumeration<FileInputStream> e = v.elements();
SequenceInputStream si = new SequenceInputStream(e);
byte[] b = new byte[1024];
int result = 0;
//先读完sPath1文件,再读sPath2文件
while((result = si.read(b)) != -1) {
System.out.println(new String(b, 0, result));
}
si.close();
}
}