Input
Deprecated
We're migrating to the new kotlinx-io library. This declaration is deprecated and will be removed in Ktor 4.0.0 If you have any problems with migration, please contact us in https://youtrack.jetbrains.com/issue/KTOR-6030/Migrate-to-new-kotlinx.io-library
Usually shouldn't be implemented directly. Inherit Input instead.
Inheritors
Constructors
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
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 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.