indexOf
Returns an index of byte first occurrence in the range of startIndex to endIndex, or -1
when the range doesn't contain byte.
The scan terminates at either endIndex or buffers' exhaustion, whichever comes first.
Parameters
the value to find.
the start of the range (inclusive) to find byte, 0
by default.
the end of the range (exclusive) to find byte, Buffer.size by default.
Throws
when the source is closed.
when startIndex > endIndex
or either of indices is negative.
Samples
Returns the index of the first match for byteString in the source at or after startIndex. This expands the source's buffer as necessary until byteString is found. This reads an unbounded number of bytes into the buffer. Returns -1
if the stream is exhausted before the requested bytes are found.
For empty byte strings this function returns startIndex if it lays within underlying buffer's bounds, 0
if startIndex was negative and the size of the underlying buffer if startIndex exceeds its size. If the startIndex value was greater than the underlying buffer's size, the data will be fetched and buffered despite the byteString is empty.
Parameters
the sequence of bytes to find within the source.
the index into the source to start searching from.
Throws
if the source is closed.
when some I/O error occurs.
Samples
Returns the index of the first match for byteString in the buffer at or after startIndex.
For empty byte strings this function returns startIndex if it lays within buffer's bounds, 0
if startIndex was negative and Buffer.size if it was greater or equal to Buffer.size.
Parameters
the sequence of bytes to find within the buffer.
the index into the buffer to start searching from.
Samples
Returns an index of byte first occurrence in the range of startIndex to endIndex, or -1
when the range doesn't contain byte.
The scan terminates at either endIndex or source's exhaustion, whichever comes first. The maximum number of bytes scanned is toIndex-fromIndex
. If byte not found in buffered data, endIndex is yet to be reached and the underlying source is not yet exhausted then new data will be read from the underlying source into the buffer.
Parameters
the value to find.
the start of the range (inclusive) to find byte, 0
by default.
the end of the range (exclusive) to find byte, Long.MAX_VALUE by default.
Throws
when the source is closed.
when startIndex > endIndex
or either of indices is negative.
when some I/O error occurs.