Contents | Prev | Next | Index

22.8 The Class java.io.SequenceInputStream

A SequenceInputStream represents the logical concatenation of other input streams. It starts out with an ordered collection of input streams and reads from the first one until end of file is reached, whereupon it reads from the second one, and so on, until end of file is reached on the last of the contained input streams.

public class SequenceInputStream extends InputStream {
	public SequenceInputStream(Enumeration e);
	public SequenceInputStream(InputStream s1, InputStream s2);
	public int read() throws IOException;
	public int read(byte[] buf, int pos, int len)
		throws IOException, NullPointerException,
			IndexOutOfBoundsException;
	public void close() throws IOException;
}

22.8.1 public SequenceInputStream(Enumeration e)

This constructor initializes a newly created SequenceInputStream by remembering the argument, which must be an Enumeration (§21.1) that produces objects whose run-time type is InputStream (§22.3). The input streams that are produced by the enumeration will be read, in order, to provide the bytes to be read from this SequenceInputStream. After each input stream from the enumeration is exhausted, it is closed by calling its close method.

22.8.2 public SequenceInputStream(InputStream s1,
InputStream s2)

This constructor initializes a newly created SequenceInputStream by remembering the two arguments, which will be read in order, first s1 and then s2, to provide the bytes to be read from this SequenceInputStream.

22.8.3 public int read() throws IOException

Implements the read method of InputStream (§22.3.1).

22.8.4 public int read(byte[] buf, int pos, int len)
throws IOException, NullPointerException, IndexOutOfBoundsException

Overrides the read method of InputStream (§22.3.3).

22.8.5 public void close() throws IOException

This SequenceInputStream is closed. A closed SequenceInputStream cannot perform input operations and cannot be reopened.

If this stream was created from an enumeration, all remaining elements are requested from the enumeration and closed before the close method returns.

Overrides the close method of InputStream (§22.3.6).


Contents | Prev | Next | Index

Java Language Specification (HTML generated by Suzette Pelouch on February 24, 1998)
Copyright © 1996 Sun Microsystems, Inc. All rights reserved
Please send any comments or corrections to doug.kramer@sun.com