java.lang.Object | ||
↳ | java.io.InputStream | |
↳ | java.io.ByteArrayInputStream |
Fields | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
buf | The byte array containing the bytes to stream over. |
||||||||||
count | The total number of bytes initially available in the byte array
buf . |
||||||||||
mark | The current mark position. | ||||||||||
pos | The current position within the byte array. |
Public Constructors | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Constructs a new
ByteArrayInputStream on the byte array
buf . | |||||||||||
Constructs a new
ByteArrayInputStream on the byte array
buf with the initial position set to offset and the
number of bytes available set to offset + length . |
Public Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Returns the number of bytes that are available before this stream will
block.
| |||||||||||
Closes this stream and frees resources associated with this stream.
| |||||||||||
Sets a mark position in this ByteArrayInputStream.
| |||||||||||
Indicates whether this stream supports the
mark() and
reset() methods. | |||||||||||
Reads at most
len bytes from this stream and stores
them in byte array b starting at offset . | |||||||||||
Reads a single byte from the source byte array and returns it as an
integer in the range from 0 to 255.
| |||||||||||
Resets this stream to the last marked location.
| |||||||||||
Skips
count number of bytes in this InputStream. |
[Expand]
Inherited Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
From class java.io.InputStream
| |||||||||||
From class java.lang.Object
| |||||||||||
From interface java.io.Closeable
|
The total number of bytes initially available in the byte array
buf
.
The current mark position. Initially set to 0 or the offset
parameter within the constructor.
Constructs a new ByteArrayInputStream
on the byte array
buf
.
buf | the byte array to stream over. |
---|
Constructs a new ByteArrayInputStream
on the byte array
buf
with the initial position set to offset
and the
number of bytes available set to offset
+ length
.
buf | the byte array to stream over. |
---|---|
offset | the initial position in buf to start streaming from. |
length | the number of bytes available for streaming. |
Returns the number of bytes that are available before this stream will block. This method returns the number of bytes yet to be read from the source byte array.
Closes this stream and frees resources associated with this stream.
IOException | if an I/O error occurs while closing this stream. |
---|
Sets a mark position in this ByteArrayInputStream. The parameter
readlimit
is ignored. Sending reset()
will reposition the
stream back to the marked position.
readlimit | ignored. |
---|
Reads at most len
bytes from this stream and stores
them in byte array b
starting at offset
. This
implementation reads bytes from the source byte array.
b | the byte array in which to store the bytes read. |
---|---|
offset | the initial position in b to store the bytes read from
this stream. |
length | the maximum number of bytes to store in b . |
IndexOutOfBoundsException | if offset < 0 or length < 0 , or if
offset + length is greater than the size of
b . |
---|---|
NullPointerException | if b is null .
|
Reads a single byte from the source byte array and returns it as an integer in the range from 0 to 255. Returns -1 if the end of the source array has been reached.
Resets this stream to the last marked location. This implementation resets the position to either the marked position, the start position supplied in the constructor or 0 if neither has been provided.
Skips count
number of bytes in this InputStream. Subsequent
read()
s will not return these bytes unless reset()
is
used. This implementation skips count
number of bytes in the
target stream. It does nothing and returns 0 if n
is negative.
n | the number of bytes to skip. |
---|