Input
Usually shouldn't be implemented directly. Inherit AbstractInput instead.
Shouldn't be implemented directly. Inherit AbstractInput instead.
Functions
Close input including the underlying source. All pending bytes will be discarded. It is not recommended to invoke it with read operations in-progress concurrently.
Copy available bytes to the specified buffer but keep them available. The underlying implementation could trigger bytes population from the underlying source and block until any bytes available.
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.
Copy available bytes to the specified buffer but keep them available. If the underlying implementation could trigger bytes population from the underlying source and block until any bytes available
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 then it fails with an exception. It is safe to specify max > destination.writeRemaining
but 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 safe to specify too big offset but only if min = 0
, fails otherwise. This function usually copy more bytes than min (unless max = min
).
Copy available bytes to the specified buffer but keep them available. If the underlying implementation could trigger bytes population from the underlying source and block until any bytes available
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 then it fails with an exception. It is safe to specify max > destination.writeRemaining
but 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 safe to specify too big offset but only if min = 0
, fails otherwise. This function usually copy more bytes than min (unless max = min
).
Properties
Inheritors
Extensions
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, AbstractInput and AbstractOutput are always optimized so no bytes will be copied.
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
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.
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 then it simply return number of available bytes with no exception so the returned value need to be checked. It is safe to specify max > destination.writeRemaining
but 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 safe to specify too big offset so in this case this function will always return 0
. 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 Input.endOfInput.
Reads at most max characters decoding bytes with specified decoder. Extra character bytes will remain unconsumed
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 array at offset at most length bytes or until one of the specified delimiters delimiter1 or delimiter2 occurred.
Copies to dst output 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
Invoke block function for every chunk until end of input or block function return zero block function returns number of bytes required to read next primitive and shouldn't require too many bytes at once otherwise it could fail with an exception. It is not guaranteed that every chunk will have fixed size but it will be always at least requested bytes length. block function should never release provided buffer and should not write to it otherwise an undefined behaviour could be observed