public class BlockingWritableByteChannel
extends java.lang.Object
implements java.nio.channels.GatheringByteChannel, java.io.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,
java.util.concurrent.TimeUnit writeTimeoutUnit)
Construct a new instance.
|
Modifier and Type | Method and Description |
---|---|
void |
close() |
void |
flush() |
boolean |
isOpen() |
void |
setWriteTimeout(long writeTimeout,
java.util.concurrent.TimeUnit writeTimeoutUnit)
Set the write timeout.
|
int |
write(java.nio.ByteBuffer src)
Perform a blocking write operation.
|
long |
write(java.nio.ByteBuffer[] srcs)
Perform a blocking, gathering write operation.
|
long |
write(java.nio.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, java.util.concurrent.TimeUnit writeTimeoutUnit)
delegate
- the channel to forward I/O operations towriteTimeout
- the write timeoutwriteTimeoutUnit
- the write timeout unitpublic void setWriteTimeout(long writeTimeout, java.util.concurrent.TimeUnit writeTimeoutUnit)
writeTimeout
- the write timeoutwriteTimeoutUnit
- the write timeout unitpublic long write(java.nio.ByteBuffer[] srcs, int offset, int length) throws java.io.IOException
write
in interface java.nio.channels.GatheringByteChannel
srcs
- the source buffersoffset
- the offset into the destination buffer arraylength
- the number of buffers to write fromjava.io.IOException
- if an I/O error occurspublic long write(java.nio.ByteBuffer[] srcs) throws java.io.IOException
write
in interface java.nio.channels.GatheringByteChannel
srcs
- the source buffersjava.io.IOException
- if an I/O error occurspublic int write(java.nio.ByteBuffer src) throws java.io.IOException
write
in interface java.nio.channels.WritableByteChannel
src
- the source bufferjava.io.IOException
- if an I/O error occurspublic boolean isOpen()
isOpen
in interface java.nio.channels.Channel
public void flush() throws java.io.IOException
flush
in interface java.io.Flushable
java.io.IOException
public void close() throws java.io.IOException
close
in interface java.io.Closeable
close
in interface java.lang.AutoCloseable
close
in interface java.nio.channels.Channel
java.io.IOException
Copyright © 2016 JBoss, a division of Red Hat, Inc.