Android
java.io
public class

java.io.SequenceInputStream

java.lang.Object
java.io.InputStream Closeable
java.io.SequenceInputStream

SequenceInputStream is used for streaming over a sequence of streams concatenated together. Reads are taken from the first stream until it ends, then the next stream is used until the last stream returns end of file.

Summary

Public Constructors

            SequenceInputStream(InputStream s1, InputStream s2)
Constructs a new SequenceInputStream using the two streams s1 and s2 as the sequence of streams to read from.
            SequenceInputStream(Enumeration<? extends InputStream> e)
Constructs a new SequenceInputStream using the elements returned from Enumeration e as the stream sequence.

Public Methods

          int  available()
Returns a int representing then number of bytes that are available before this InputStream will block.
          void  close()
Close the SequenceInputStream.
          int  read(byte[] buffer, int offset, int count)
Reads at most count bytes from this SequenceInputStream and stores them in byte array buffer starting at offset.
          int  read()
Reads a single byte from this SequenceInputStream and returns the result as an int.
Methods inherited from class java.io.InputStream
Methods inherited from class java.lang.Object
Methods inherited from interface java.io.Closeable

Details

Public Constructors

public SequenceInputStream(InputStream s1, InputStream s2)

Constructs a new SequenceInputStream using the two streams s1 and s2 as the sequence of streams to read from.

Parameters

s1 the first stream to get bytes from
s2 the second stream to get bytes from

public SequenceInputStream(Enumeration<? extends InputStream> e)

Constructs a new SequenceInputStream using the elements returned from Enumeration e as the stream sequence. The types returned from nextElement() must be of InputStream.

Parameters

e the Enumeration of InputStreams to get bytes from

Public Methods

public int available()

Returns a int representing then number of bytes that are available before this InputStream will block.

Returns

  • the number of bytes available before blocking.

Throws

IOException If an error occurs in this InputStream.

public void close()

Close the SequenceInputStream. All streams in this sequence are closed before returning from this method. This stream cannot be used for input once it has been closed.

Throws

IOException If an error occurs attempting to close this FileInputStream.

public int read(byte[] buffer, int offset, int count)

Reads at most count bytes from this SequenceInputStream and stores them in byte array buffer starting at offset. Answer the number of bytes actually read or -1 if no bytes were read and end of stream was encountered.

Parameters

buffer the byte array in which to store the read bytes.
offset the offset in buffer to store the read bytes.
count the maximum number of bytes to store in buffer.

Returns

  • the number of bytes actually read or -1 if end of stream.

Throws

IOException If an error occurs while reading the stream

public int read()

Reads a single byte from this SequenceInputStream and returns the result as an int. The low-order byte is returned or -1 of the end of stream was encountered. The current stream is read from. If it reaches the end of file, the next stream is read from.

Returns

  • the byte read or -1 if end of stream.

Throws

IOException If an error occurs while reading the stream
Copyright 2007 Google Inc. Build 0.9_r1-98467 - 14 Aug 2008 18:56