public class BlockingWritableByteChannel extends Object implements GatheringByteChannel, Flushable
StreamChannel
. Write operations will block until some data may be transferred.
Once any amount of data is written, the operation will return. If a write timeout is specified, then the write methods
will throw a WriteTimeoutException
if the timeout expires without writing any data.Constructor and Description |
---|
BlockingWritableByteChannel(StreamSinkChannel delegate)
Construct a new instance.
|
BlockingWritableByteChannel(StreamSinkChannel delegate,
long writeTimeout,
TimeUnit writeTimeoutUnit)
Construct a new instance.
|
Modifier and Type | Method and Description |
---|---|
void |
close() |
void |
flush() |
boolean |
isOpen() |
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 BlockingWritableByteChannel(StreamSinkChannel delegate)
delegate
- the channel to forward I/O operations topublic BlockingWritableByteChannel(StreamSinkChannel delegate, long writeTimeout, TimeUnit writeTimeoutUnit)
delegate
- the channel to forward I/O operations towriteTimeout
- the write timeoutwriteTimeoutUnit
- the write timeout unitpublic void setWriteTimeout(long writeTimeout, TimeUnit writeTimeoutUnit)
writeTimeout
- the write timeoutwriteTimeoutUnit
- the write timeout unitpublic 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 © 2021 JBoss by Red Hat. All rights reserved.