Java IO Tutorial - Java SequenceInputStream (Enumeration <? extends InputStream > e) Constructor








Syntax

SequenceInputStream(Enumeration <? extends InputStream > e) constructor from SequenceInputStream has the following syntax.

public SequenceInputStream(Enumeration <? extends InputStream > e)

Example

In the following code shows how to use SequenceInputStream.SequenceInputStream(Enumeration <? extends InputStream > e) constructor.

import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.SequenceInputStream;
import java.util.Vector;
/*  www. j  a  v a 2s. c  om*/
public class Main {

  public static void main(String[] args) throws IOException {

    Vector theStreams = new Vector();

    for (int i = 0; i < args.length; i++) {
      FileInputStream fin = new FileInputStream(args[i]);
      theStreams.addElement(fin);
    }

    InputStream in = new SequenceInputStream(theStreams.elements());
    for (int i = in.read(); i != -1; i = in.read()) {
      System.out.write(i);
    }
  }
}