class hello {
public static void main(String[] args) throws IOException {
FileInputStream input1 = new FileInputStream("input1.txt");
FileInputStream input2 = new FileInputStream("input2.txt");
FileInputStream input3 = new FileInputStream("input3.txt");
FileInputStream input4 = new FileInputStream("input4.txt");
Vector<FileInputStream> v = new Vector<>();
v.add(input1);
v.add(input2);
v.add(input3);
v.add(input4);
Enumeration<FileInputStream> elements = v.elements();
SequenceInputStream SIS = new SequenceInputStream(elements);
FileOutputStream output = new FileOutputStream("output.txt");
int a;
while((a = SIS.read()) != -1) {
output.write(a);
}
input1.close();
input2.close();
SIS.close();
output.close();
}
运行结果: