public class BlockingByteChannel extends Object implements ScatteringByteChannel, GatheringByteChannel, ByteChannel, Flushable
StreamChannel
. Read and write operations will block until some data may be transferred.
Once any amount of data is read or written, the operation will return.Constructor and Description |
---|
BlockingByteChannel(StreamChannel delegate)
Construct a new instance.
|
BlockingByteChannel(StreamChannel delegate,
long timeout,
TimeUnit timeoutUnit)
Construct a new instance.
|
BlockingByteChannel(StreamChannel delegate,
long readTimeout,
TimeUnit readTimeoutUnit,
long writeTimeout,
TimeUnit writeTimeoutUnit)
Construct a new instance.
|
Modifier and Type | Method and Description |
---|---|
void |
close() |
void |
flush() |
boolean |
isOpen() |
int |
read(ByteBuffer dst)
Perform a blocking read operation.
|
long |
read(ByteBuffer[] dsts)
Perform a blocking, scattering read operation.
|
long |
read(ByteBuffer[] dsts,
int offset,
int length)
Perform a blocking, scattering read operation.
|
void |
setReadTimeout(long readTimeout,
TimeUnit readTimeoutUnit)
Set the read timeout.
|
void |
setWriteTimeout(long writeTimeout,
TimeUnit writeTimeoutUnit)
Set the write timeout.
|
int |
write(ByteBuffer src)
Perform a blocking write operation.
|
long |
write(ByteBuffer[] srcs)
Perform a blocking, gathering write operation.
|
long |
write(ByteBuffer[] srcs,
int offset,
int length)
Perform a blocking, gathering write operation.
|
public BlockingByteChannel(StreamChannel delegate)
delegate
- the channel to forward I/O operations topublic BlockingByteChannel(StreamChannel delegate, long timeout, TimeUnit timeoutUnit)
delegate
- the channel to forward I/O operations totimeout
- the read/write timeouttimeoutUnit
- the read/write timeout unitpublic BlockingByteChannel(StreamChannel delegate, long readTimeout, TimeUnit readTimeoutUnit, long writeTimeout, TimeUnit writeTimeoutUnit)
delegate
- the channel to forward I/O operations toreadTimeout
- the read timeoutreadTimeoutUnit
- the read timeout unitwriteTimeout
- the write timeoutwriteTimeoutUnit
- the write timeout unitpublic void setReadTimeout(long readTimeout, TimeUnit readTimeoutUnit)
readTimeout
- the read timeoutreadTimeoutUnit
- the read timeout unitpublic void setWriteTimeout(long writeTimeout, TimeUnit writeTimeoutUnit)
writeTimeout
- the write timeoutwriteTimeoutUnit
- the write timeout unitpublic long read(ByteBuffer[] dsts, int offset, int length) throws IOException
read
in interface ScatteringByteChannel
dsts
- the destination buffersoffset
- the offset into the destination buffer arraylength
- the number of buffers to read intoIOException
- if an I/O error occurspublic long read(ByteBuffer[] dsts) throws IOException
read
in interface ScatteringByteChannel
dsts
- the destination buffersIOException
- if an I/O error occurspublic int read(ByteBuffer dst) throws IOException
read
in interface ReadableByteChannel
dst
- the destination bufferIOException
- if an I/O error occurspublic long write(ByteBuffer[] srcs, int offset, int length) throws IOException
write
in interface GatheringByteChannel
srcs
- the source buffersoffset
- the offset into the destination buffer arraylength
- the number of buffers to write fromIOException
- if an I/O error occurspublic long write(ByteBuffer[] srcs) throws IOException
write
in interface GatheringByteChannel
srcs
- the source buffersIOException
- if an I/O error occurspublic int write(ByteBuffer src) throws IOException
write
in interface WritableByteChannel
src
- the source bufferIOException
- if an I/O error occurspublic void flush() throws IOException
flush
in interface Flushable
IOException
public void close() throws IOException
close
in interface Closeable
close
in interface AutoCloseable
close
in interface Channel
IOException
Copyright © 2012 JBoss by Red Hat. All Rights Reserved.