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 remaining bytes.
| |||||||||||
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 a single byte from the source byte array and returns it as an
integer in the range from 0 to 255.
| |||||||||||
Reads up to
byteCount bytes from this stream and stores them in
the byte array buffer starting at byteOffset . | |||||||||||
Resets this stream to the last marked location.
| |||||||||||
Skips
byteCount bytes in this InputStream. |
[Expand]
Inherited Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
From class
java.io.InputStream
| |||||||||||
From class
java.lang.Object
| |||||||||||
From interface
java.io.Closeable
| |||||||||||
From interface
java.lang.AutoCloseable
|
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 remaining bytes.
count - pos
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 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.
Reads up to byteCount
bytes from this stream and stores them in
the byte array buffer
starting at byteOffset
.
Returns the number of bytes actually read or -1 if the end of the stream
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 byteCount
bytes in this InputStream. Subsequent
calls to read
will not return these bytes unless reset
is
used. This implementation skips byteCount
number of bytes in the
target stream. It does nothing and returns 0 if byteCount
is negative.