Combining multiple InputStreams

You can combine two or more inputstreams with the class SequenceInputStream. It allows
you to put them next to each other, in sequence:

           SequenceInputStream
           +-----------------------+
           |  +-----+-----+-----+  |
 read() <--+  | IS1 | IS2 | IS3 |  |
           |  +-----+-----+-----+  |
           +-----------------------+

There are two ways to construct a SequenceInputStream through its two constructors. You could either pass an enumeration of all your inputstreams, or you can pass in two inputstreams.
The following example allows you to specify two filenames which will be printed out on the console.

Main.java:

import java.util.*;
import java.io.*;
  
public class Main {   
   public static void main(String[] args) throws Exception {
      if (args.length != 2) {
         System.out.println("Usage: java Main <filename1> <filename2>");
         System.exit(1);
      }
 
      FileInputStream fis1 = new FileInputStream(args[0]);
      FileInputStream fis2 = new FileInputStream(args[1]);
 
      SequenceInputStream sis = new SequenceInputStream(fis1, fis2);
      int k;
      while ((k = sis.read()) > -1) {
         System.out.print((char) k);
      }
   }
}

(try it out with two small textfiles :)