Package org.xnio.channels
Class BlockingReadableByteChannel
java.lang.Object
org.xnio.channels.BlockingReadableByteChannel
- All Implemented Interfaces:
Closeable,AutoCloseable,Channel,ReadableByteChannel,ScatteringByteChannel
A blocking wrapper for a
StreamSourceChannel. Read operations will block until some data may be transferred.
Once any amount of data is read, the operation will return. If a read timeout is specified, then the read methods
will throw a ReadTimeoutException if the timeout expires without reading any data.-
Constructor Summary
ConstructorsConstructorDescriptionConstruct a new instance.BlockingReadableByteChannel(StreamSourceChannel delegate, long readTimeout, TimeUnit readTimeoutUnit) Construct a new instance. -
Method Summary
Modifier and TypeMethodDescriptionvoidclose()booleanisOpen()intread(ByteBuffer dst) Perform a blocking read operation.longread(ByteBuffer[] dsts) Perform a blocking, scattering read operation.longread(ByteBuffer[] dsts, int offset, int length) Perform a blocking, scattering read operation.voidsetReadTimeout(long readTimeout, TimeUnit readTimeoutUnit) Set the read timeout.
-
Constructor Details
-
BlockingReadableByteChannel
Construct a new instance.- Parameters:
delegate- the channel to forward I/O operations to
-
BlockingReadableByteChannel
public BlockingReadableByteChannel(StreamSourceChannel delegate, long readTimeout, TimeUnit readTimeoutUnit) Construct a new instance.- Parameters:
delegate- the channel to forward I/O operations toreadTimeout- the read timeoutreadTimeoutUnit- the read timeout unit
-
-
Method Details
-
setReadTimeout
Set the read timeout.- Parameters:
readTimeout- the read timeoutreadTimeoutUnit- the read timeout unit
-
read
Perform a blocking, scattering read operation.- Specified by:
readin interfaceScatteringByteChannel- Parameters:
dsts- the destination buffersoffset- the offset into the destination buffer arraylength- the number of buffers to read into- Returns:
- the number of bytes actually read (will be greater than zero)
- Throws:
IOException- if an I/O error occurs
-
read
Perform a blocking, scattering read operation.- Specified by:
readin interfaceScatteringByteChannel- Parameters:
dsts- the destination buffers- Returns:
- the number of bytes actually read (will be greater than zero)
- Throws:
IOException- if an I/O error occurs
-
read
Perform a blocking read operation.- Specified by:
readin interfaceReadableByteChannel- Parameters:
dst- the destination buffer- Returns:
- the number of bytes actually read (will be greater than zero)
- Throws:
IOException- if an I/O error occurs
-
isOpen
public boolean isOpen() -
close
- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceChannel- Specified by:
closein interfaceCloseable- Throws:
IOException
-