Sequence IO Stream


Sequence IO Stream

Sequence IO Stream:
A Sequence Input Stream takes a list of Sources and start reading from the first source. Once the end of the current source is reached, it moves on to read from the next source in list. This mechanism continues up until the last source end is reached.


Below is an example of Sequence Input Stream



// A vector containing a list of 'N' Input Sources
Vector inputStreamList = new Vector();
inputStreamList.add(new FileInputStream("filereader.txt"));
inputStreamList.add(new FileInputStream("filterstream.txt"));

// Creating a Sequence Input Stream passing an Enumerator of the Input Sources
SequenceInputStream sequenceInputStream = new SequenceInputStream(inputStreamList.elements());
  
int eachInput;

// Reading each Source in Sequence
while( (eachInput = sequenceInputStream.read()) != -1 )
{
 System.out.print( (char) eachInput);
}


<< Piped IO Stream Random Access IO Stream >>

No comments:

Post a Comment