The role of Bytearrayinputstream:
Contains an internal buffer that contains bytes that can be read from the stream. The internal counter tracks read the next byte provided by the method. Close one ByteArrayInputStream without any effect. The methods in the stream can be called after the stream is closed, not generated IOException . This means that, for example, a file stream handles a file in the external memory of an object, and its processing object is an in-memory buffer. It is read from one memory to another in memory mode.
Fields
| Modifier and Type |
Field |
Description |
protected byte[] |
buf |
An array of bytes provided by the creator of the data stream. |
protected int |
count |
Index one is greater than the last valid character in the input stream buffer. |
protected int |
mark |
The position of the current marker in the stream. |
protected int |
pos |
The index of the next character read from the input stream buffer. |
construction method
| constructor |
Description |
Bytearrayinputstream? (byte[] buf) |
Bytearrayinputstream that uses buf as its buffer array. |
By Tearrayinputstream? (Byte[] buf, Int offset, int length) |
Create bytearrayinputstream use buf as its buffer array. |
| Modifier and Type |
Method |
Description |
int |
available?() |
Returns the number of bytes remaining that can be read (or skipped) from this input stream. |
void |
close?() |
Close one ByteArrayInputStream without any effect. |
void |
mark?(int readAheadLimit) |
Sets the position of the current marker in the stream. |
boolean |
markSupported?() |
Test this InputStream support tag/reset. |
int |
read?() |
Reads the next data byte from the input stream. |
int |
read?(byte[] b, int off, int len) |
Reads up len to a byte array of data from the input stream. |
void |
reset?() |
Resets the buffer to the marker position. |
long |
skip?(long n) |
Skips the byte input of this input stream n . |
Note:
Public bytearrayinputstream? (byte[] buf, int offset, int length)
Create
ByteArrayInputStreamUse
bufAs its buffer array.
posIs
offsetAnd the initial value,
countis the smallest
offset+lengthAnd
buf.length。 The buffer array is not copied. The marker for the buffer is set to the specified offset.
- Parameters
-
buf -Input buffer.
-
offset -The offset in the buffer to read the first byte.
-
length -The maximum number of bytes read from the buffer.
Bytearrayinputstream of Java Byte stream