Creates a <code>ByteArrayInputStream</code> so that it uses <code>buf</code> as its buffer array. The buffer array is not copied. The initial value of <code>pos</code> is <code>0</code> and the initial value of <code>count</code> is the length of <code>buf</code>.
Creates <code>ByteArrayInputStream</code> that uses <code>buf</code> as its buffer array. The initial value of <code>pos</code> is <code>offset</code> and the initial value of <code>count</code> is the minimum of <code>offset+length</code> and <code>buf.length</code>. The buffer array is not copied. The buffer's mark is set to the specified offset.
Returns the number of remaining bytes that can be read (or skipped over) from this input stream. <p> The value returned is <code>count - pos</code>, which is the number of bytes remaining to be read from the input buffer.
Set the current marked position in the stream. ByteArrayInputStream objects are marked at position zero by default when constructed. They may be marked at another position within the buffer by this method. <p> If no mark has been set, then the value of the mark is the offset passed to the constructor (or 0 if the offset was not supplied).
Tests if this <code>InputStream</code> supports mark/reset. The <code>markSupported</code> method of <code>ByteArrayInputStream</code> always returns <code>true</code>.
Reads the next byte of data from this input stream. The value byte is returned as an <code>int</code> in the range <code>0</code> to <code>255</code>. If no byte is available because the end of the stream has been reached, the value <code>-1</code> is returned. <p> This <code>read</code> method cannot block.
Reads up to <code>len</code> bytes of data into an array of bytes from this input stream. If <code>pos</code> equals <code>count</code>, then <code>-1</code> is returned to indicate end of file. Otherwise, the number <code>k</code> of bytes read is equal to the smaller of <code>len</code> and <code>count-pos</code>. If <code>k</code> is positive, then bytes <code>bufpos</code> through <code>buf[pos+k-1]</code> are copied into <code>boff</code> through <code>b[off+k-1]</code> in the manner performed by <code>System.arraycopy</code>. The value <code>k</code> is added into <code>pos</code> and <code>k</code> is returned. <p> This <code>read</code> method cannot block.
Resets the buffer to the marked position. The marked position is 0 unless another position was marked or an offset was specified in the constructor.
Skips <code>n</code> bytes of input from this input stream. Fewer bytes might be skipped if the end of the input stream is reached. The actual number <code>k</code> of bytes to be skipped is equal to the smaller of <code>n</code> and <code>count-pos</code>. The value <code>k</code> is added into <code>pos</code> and <code>k</code> is returned.
The currently marked position in the stream. ByteArrayInputStream objects are marked at position zero by default when constructed. They may be marked at another position within the buffer by the <code>mark()</code> method. The current buffer position is set to this point by the <code>reset()</code> method. <p> If no mark has been set, then the value of mark is the offset passed to the constructor (or 0 if the offset was not supplied).
An array of bytes that was provided by the creator of the stream. Elements <code>buf[0]</code> through <code>buf[count-1]</code> are the only bytes that can ever be read from the stream; element <code>bufpos</code> is the next byte to be read.
The index one greater than the last valid character in the input stream buffer. This value should always be nonnegative and not larger than the length of <code>buf</code>. It is one greater than the position of the last byte within <code>buf</code> that can ever be read from the input stream buffer.
The index of the next character to read from the input stream buffer. This value should always be nonnegative and not larger than the value of <code>count</code>. The next byte to be read from the input stream buffer will be <code>bufpos</code>.
Reads the next byte of data from the input stream. The value byte is returned as an <code>int</code> in the range <code>0</code> to <code>255</code>. If no byte is available because the end of the stream has been reached, the value <code>-1</code> is returned. This method blocks until input data is available, the end of the stream is detected, or an exception is thrown.
Reads some number of bytes from the input stream and stores them into the buffer array <code>b</code>. The number of bytes actually read is returned as an integer. This method blocks until input data is available, end of file is detected, or an exception is thrown.
Reads up to <code>len</code> bytes of data from the input stream into an array of bytes. An attempt is made to read as many as <code>len</code> bytes, but a smaller number may be read. The number of bytes actually read is returned as an integer.
Skips over and discards <code>n</code> bytes of data from this input stream. The <code>skip</code> method may, for a variety of reasons, end up skipping over some smaller number of bytes, possibly <code>0</code>. This may result from any of a number of conditions; reaching end of file before <code>n</code> bytes have been skipped is only one possibility. The actual number of bytes skipped is returned. If {@code n} is negative, the {@code skip} method for class {@code InputStream} always returns 0, and no bytes are skipped. Subclasses may handle the negative value differently.
Returns an estimate of the number of bytes that can be read (or skipped over) from this input stream without blocking by the next invocation of a method for this input stream. The next invocation might be the same thread or another thread. A single read or skip of this many bytes will not block, but may read or skip fewer bytes.
Closes this input stream and releases any system resources associated with the stream.
Marks the current position in this input stream. A subsequent call to the <code>reset</code> method repositions this stream at the last marked position so that subsequent reads re-read the same bytes.
Repositions this stream to the position at the time the <code>mark</code> method was last called on this input stream.
set a new position
Tests if this input stream supports the <code>mark</code> and <code>reset</code> methods. Whether or not <code>mark</code> and <code>reset</code> are supported is an invariant property of a particular input stream instance. The <code>markSupported</code> method of <code>InputStream</code> returns <code>false</code>.
A <code>ByteArrayInputStream</code> contains an internal buffer that contains bytes that may be read from the stream. An internal counter keeps track of the next byte to be supplied by the <code>read</code> method. <p> Closing a <tt>ByteArrayInputStream</tt> has no effect. The methods in this class can be called after the stream has been closed without generating an <tt>IOException</tt>.