ByteArrayInputStream

Name

A ByteArrayInputStream
is a stream whose data comes from a byte array. None of the methods of
this class throw an IOException
because the data comes from an array instead of an actual I/O device.
This class does not support the ability to mark a position in the stream.
A call to reset(), however,
does position the stream at the beginning of the byte array.

The position of the end of the stream depends on the constructor used.
If the ByteArrayInputStream(byte[] buf)
constructor is used, the end of the stream is the end of the byte array.
If the ByteArrayInputStream(byte[] buf, int offset, int
length) constructor is used, the end of the
stream is reached at the index given by offset+length.

This constructor creates a ByteArrayInputStream
object that uses the given array of bytes as its data source. The data
is not copied, so changes made to the array affect the data the ByteArrayInputStream
returns.

This constructor creates a ByteArrayInputStream
that uses, as its data source, length
bytes in a given array of bytes, starting at offset
bytes from the beginning of the array. The data is not copied, so changes
made to the array affect the data the ByteArrayInputStream
returns.

This method resets the position of the input stream to the beginning of
the byte array. If you specified an offset into the array, you might expect
this method to reset the position to where you first started reading from
the stream, but that is not the case.