The SequenceInputStream Class : Enumeration Interface « Collections « Java Tutorial






import java.io.BufferedReader;
import java.io.FileInputStream;
import java.io.InputStreamReader;
import java.io.SequenceInputStream;
import java.util.Enumeration;
import java.util.Vector;

public class MainClass {
  public static void main(String args[]) throws Exception {
    Vector v = new Vector(3);
    v.add(new FileInputStream("/a/b"));
    v.add(new FileInputStream("yourfile.bar"));
    v.add(new FileInputStream("/yourfile.txt"));

    Enumeration e = v.elements();
    SequenceInputStream sis = new SequenceInputStream(e);
    InputStreamReader isr = new InputStreamReader(sis);
    BufferedReader br = new BufferedReader(isr);
    String line;
    while ((line = br.readLine()) != null) {
      System.out.println(line);
    }
    br.close();
  }
}








9.35.Enumeration Interface
9.35.1.The Enumeration Interface
9.35.2.If you prefer a for-loop
9.35.3.Where do we get the enumeration from?
9.35.4.The SequenceInputStream Class
9.35.5.Concatenates the content of two enumerations into one.
9.35.6.Filters enumeration to contain each of the provided elements just once.
9.35.7.Filters some elements out from the input enumeration.
9.35.8.For each element of the input enumeration asks the Processor to provide a replacement
9.35.9.Removes all nulls from the input enumeration.
9.35.10.Returns an enumeration that iterates over provided array.
9.35.11.Support for breadth-first enumerating.
9.35.12.Serializable Enumeration
9.35.13.An enumeration that iterates over an array.
9.35.14.Creating Custom Enumerations