ByteReadChannel
Channel for asynchronous reading of sequences of bytes. This is a single-reader channel.
Operations on this channel cannot be invoked concurrently.
Channel for asynchronous reading of sequences of bytes. This is a single-reader channel.
Operations on this channel cannot be invoked concurrently.
Channel for asynchronous reading of sequences of bytes. This is a single-reader channel.
Operations on this channel cannot be invoked concurrently.
Types
Functions
Close channel with optional cause cancellation. Unlike ByteWriteChannel.close that could close channel normally, cancel does always close with error so any operations on this channel will always fail and all suspensions will be resumed with exception.
Close channel with optional cause cancellation. Unlike ByteWriteChannel.close that could close channel normally, cancel does always close with error so any operations on this channel will always fail and all suspensions will be resumed with exception.
Close channel with optional cause cancellation. Unlike ByteWriteChannel.close that could close channel normally, cancel does always close with error so any operations on this channel will always fail and all suspensions will be resumed with exception.
For every available bytes range invokes visitor function until it return false or end of stream encountered
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 suspending reading. 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 isClosedForRead.
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 suspending reading. 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.
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 suspending reading. 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.
Invokes consumer when it will be possible to read at least min bytes providing byte buffer to it so lambda can read from the buffer up to ByteBuffer.remaining bytes. If there are no min bytes available then the invocation could suspend until the requirement will be met.
Reads all available bytes to dst buffer and returns immediately or suspends if no bytes available
Invokes block if it is possible to read at least min byte providing byte buffer to it so lambda can read from the buffer up to ByteBuffer.available bytes. If there are no min bytes available then the invocation returns 0.
Reads all available bytes to dst buffer and returns immediately or suspends if no bytes available
Reads all available bytes to dst buffer and returns immediately or suspends if no bytes available
Reads a boolean value (suspending if no bytes available yet) or fails if channel has been closed and not enough bytes.
Reads a boolean value (suspending if no bytes available yet) or fails if channel has been closed and not enough bytes.
Reads a boolean value (suspending if no bytes available yet) or fails if channel has been closed and not enough bytes.
Reads a byte (suspending if no bytes available yet) or fails if channel has been closed and not enough bytes.
Reads a byte (suspending if no bytes available yet) or fails if channel has been closed and not enough bytes.
Reads double number (suspending if not enough bytes available) or fails if channel has been closed and not enough bytes.
Reads double number (suspending if not enough bytes available) or fails if channel has been closed and not enough bytes.
Reads double number (suspending if not enough bytes available) or fails if channel has been closed and not enough bytes.
Reads float number (suspending if not enough bytes available) or fails if channel has been closed and not enough bytes.
Reads float number (suspending if not enough bytes available) or fails if channel has been closed and not enough bytes.
Reads all length bytes to dst buffer or fails if channel has been closed. Suspends if not enough bytes available.
Reads an int number (suspending if not enough bytes available) or fails if channel has been closed and not enough bytes.
Reads an int number (suspending if not enough bytes available) or fails if channel has been closed and not enough bytes.
Reads a long number (suspending if not enough bytes available) or fails if channel has been closed and not enough bytes.
Reads a long number (suspending if not enough bytes available) or fails if channel has been closed and not enough bytes.
Reads the specified amount of bytes and makes a byte packet from them. Fails if channel has been closed and not enough bytes available. Accepts headerSizeHint to be provided, see BytePacketBuilder.
Reads the specified amount of bytes and makes a byte packet from them. Fails if channel has been closed and not enough bytes available. Accepts headerSizeHint to be provided, see WritePacket.
Reads the specified amount of bytes and makes a byte packet from them. Fails if channel has been closed and not enough bytes available. Accepts headerSizeHint to be provided, see BytePacketBuilder.
Reads up to limit bytes and makes a byte packet or until end of stream encountered. Accepts headerSizeHint to be provided, see BytePacketBuilder.
Reads up to limit bytes and makes a byte packet or until end of stream encountered. Accepts headerSizeHint to be provided, see BytePacketBuilder.
Reads up to limit bytes and makes a byte packet or until end of stream encountered. Accepts headerSizeHint to be provided, see BytePacketBuilder.
Starts non-suspendable read session. After channel preparation consumer lambda will be invoked immediately event if there are no bytes available for read yet.
Starts non-suspendable read session. After channel preparation consumer lambda will be invoked immediately even if there are no bytes available for read yet.
Starts non-suspendable read session. After channel preparation consumer lambda will be invoked immediately event if there are no bytes available for read yet.
Reads a short number (suspending if not enough bytes available) or fails if channel has been closed and not enough bytes.
Reads a short number (suspending if not enough bytes available) or fails if channel has been closed and not enough bytes.
Properties
Returns true
if the channel is closed and no remaining bytes are available for read. It implies that availableForRead is zero.
Returns true
if the channel is closed and no remaining bytes are available for read. It implies that availableForRead is zero.
Returns true
if the channel is closed and no remaining bytes are available for read. It implies that availableForRead is zero.
Byte order that is used for multi-byte read operations (such as readShort, readInt, readLong, readFloat, and readDouble).
Byte order that is used for multi-byte read operations (such as readShort, readInt, readLong, readFloat, and readDouble).
Byte order that is used for multi-byte read operations (such as readShort, readInt, readLong, readFloat, and readDouble).
Inheritors
Extensions
For every available bytes range invokes visitor function until it return false or end of stream encountered. The provided buffer should be never captured outside of the visitor block otherwise resource leaks, crashes and data corruptions may occur. The visitor block may be invoked multiple times, once or never.
Reads bytes from receiver channel and writes them to dst channel. Closes dst channel if fails to read or write with cause exception.
Copy up to limit bytes to blocking NIO channel. Copying to non-blocking channel requires selection and not supported. It does suspend if no data available in byte channel but may block if destination NIO channel blocks.
Copies up to limit bytes from this byte channel to out stream suspending on read channel and blocking on output
Discards all bytes in the channel and suspends until end of stream.
Discards exactly n bytes or fails if not enough bytes in the channel
Await until at least desiredSize is available for read or EOF and invoke block function. The block function should never capture a provided Memory instance outside otherwise an undefined behaviour may occur including accidental crash or data corruption. Block function should return number of bytes consumed or 0.
Reads the specified amount of bytes and makes a byte packet from them. Fails if channel has been closed and not enough bytes available.
Reads up to limit bytes and makes a byte packet or until end of stream encountered.
Reads all remaining bytes and makes a byte packet
Reads from the channel to the specified dst byte buffer until one of the following:
Create blocking java.io.InputStream for this channel that does block every time the channel suspends at read Similar to do reading in runBlocking however you can pass it to regular blocking API