ByteReadPacket
Properties
It is true
when it is known that no more bytes will be available. When it is false
then this means that it is not known yet or there are available bytes. Please note that false
value doesn't guarantee that there are available bytes so readByte()
may fail.
For streaming input it should be Input.endOfInput instead.
For streaming input there is no reliable way to detect it without triggering bytes population from the underlying source. Consider using Input.endOfInput or use ByteReadPacket instead.
Functions
Returns a copy of the packet. The original packet and the copy could be used concurrently. Both need to be either completely consumed or released via release
Copy all bytes to the output. Depending on actual input and output implementation it could be zero-copy or copy byte per byte. All regular types such as ByteReadPacket, BytePacketBuilder, Input and Output are always optimized so no bytes will be copied.
Discards exactly n bytes or fails with EOFException
Discard exactly n bytes or fail if not enough bytes in the input to be discarded.
Discards bytes until delimiter occurred
Discards bytes until of of the specified delimiters delimiter1 or delimiter2 occurred
Try to copy at least min but up to max bytes to the specified destination buffer from this input skipping offset bytes. If there are not enough bytes available to provide min bytes after skipping offset bytes then it will trigger the underlying source reading first and after that will simply copy available bytes even if EOF encountered so min is not a requirement but a desired number of bytes. It is safe to specify max greater than the destination free space. min
shouldn't be bigger than the destination free space. This function could trigger the underlying source reading that may lead to blocking I/O. It is allowed to specify too big offset so in this case this function will always return 0
after prefetching all underlying bytes but note that it may lead to significant memory consumption. This function usually copy more bytes than min (unless max = min
) but it is not guaranteed. When 0
is returned with offset = 0
then it makes sense to check endOfInput.
Read exactly n bytes to a new array buffer instance
Read exactly n bytes to a new array buffer instance
Reads all remaining bytes from the input
Read exactly n bytes (consumes all remaining if n is not specified but up to Int.MAX_VALUE bytes). Does fail if not enough bytes remaining.
Reads exactly n bytes from the input or fails if not enough bytes available.
Read a string exactly exactCharacters length
Read exactly exactCharacters characters and append them to out
Read exactly the specified number of bytes interpreting bytes in the specified charset (optional, UTF-8 by default).
Read exactly bytesCount interpreting bytes in the specified charset (optional, UTF-8 by default).
Read exactly charactersCount characters interpreting bytes in the specified charset.
Copies to dst output until one of the specified delimiters delimiter1 or delimiter2 occurred.
Copies to dst array at offset at most length bytes or until one of the specified delimiters delimiter1 or delimiter2 occurred.
Reads UTF-8 line and append all line characters to out except line endings. Supports CR, LF and CR+LF
Reads UTF-8 characters until one of the specified delimiters found, limit exceeded or end of stream encountered
Reads UTF-8 characters to out buffer until one of the specified delimiters found, limit exceeded or end of stream encountered
Release packet. After this function invocation the packet becomes empty. If it has been copied via ByteReadPacket.copy then the copy should be released as well.