SdkByteChannel
Channel for asynchronous reading and writing sequences of bytes. Conceptually a pipe with a reader on one end, decoupled from a writer on the other.
This is a buffered single-reader single writer channel.
Read operations can be invoked concurrently with write operations, but multiple reads or multiple writes cannot be invoked concurrently with themselves. Exceptions are close and flush which can be invoked concurrently with other operations including between themselves at any time.
Inherited properties
Returns number of bytes that can be read without suspension. Read operations do no suspend and return immediately when this number is at least the number of bytes requested for read.
Returns the number of bytes that can be written without suspension. Write operations do not suspend and return immediately when this number is at least the number of bytes requested for write.
Returns the underlying cause the channel was closed with or null
if closed successfully or not yet closed. A failed channel will have a closed cause.
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 from the writer side. availableForRead may be 0
Total number of bytes written to the channel.
Functions
Inherited functions
Read exactly byteCount bytes from this into sink or throws EOFException if the channel is exhausted before all bytes could be read.
Caution Read the entire contents of the channel into sink. This function will suspend until the channel is exhausted and no bytes remain OR the channel cancelled
Caution Read the entire contents of the channel into a new buffer and return it. This function will suspend until the channel is exhausted and no bytes remain OR the channel cancelled
Removes exactly byteCount bytes from source and appends them to this. Suspends until all bytes have been written. It is not safe to modify source until this function returns Throws ClosedWriteChannelException if this channel was already closed.
Convenience function to write as many bytes from source as possible without suspending. Returns the number of bytes that could be written.