- java.lang.Object
-
- org.xnio.channels.BlockingWritableByteChannel
-
- All Implemented Interfaces:
java.io.Closeable,java.io.Flushable,java.lang.AutoCloseable,java.nio.channels.Channel,java.nio.channels.GatheringByteChannel,java.nio.channels.WritableByteChannel
public class BlockingWritableByteChannel extends java.lang.Object implements java.nio.channels.GatheringByteChannel, java.io.FlushableA blocking wrapper for aStreamChannel. 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 aWriteTimeoutExceptionif the timeout expires without writing any data.
-
-
Constructor Summary
Constructors Constructor Description BlockingWritableByteChannel(StreamSinkChannel delegate)Construct a new instance.BlockingWritableByteChannel(StreamSinkChannel delegate, long writeTimeout, java.util.concurrent.TimeUnit writeTimeoutUnit)Construct a new instance.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidclose()voidflush()booleanisOpen()voidsetWriteTimeout(long writeTimeout, java.util.concurrent.TimeUnit writeTimeoutUnit)Set the write timeout.intwrite(java.nio.ByteBuffer src)Perform a blocking write operation.longwrite(java.nio.ByteBuffer[] srcs)Perform a blocking, gathering write operation.longwrite(java.nio.ByteBuffer[] srcs, int offset, int length)Perform a blocking, gathering write operation.
-
-
-
Constructor Detail
-
BlockingWritableByteChannel
public BlockingWritableByteChannel(StreamSinkChannel delegate)
Construct a new instance.- Parameters:
delegate- the channel to forward I/O operations to
-
BlockingWritableByteChannel
public BlockingWritableByteChannel(StreamSinkChannel delegate, long writeTimeout, java.util.concurrent.TimeUnit writeTimeoutUnit)
Construct a new instance.- Parameters:
delegate- the channel to forward I/O operations towriteTimeout- the write timeoutwriteTimeoutUnit- the write timeout unit
-
-
Method Detail
-
setWriteTimeout
public void setWriteTimeout(long writeTimeout, java.util.concurrent.TimeUnit writeTimeoutUnit)Set the write timeout.- Parameters:
writeTimeout- the write timeoutwriteTimeoutUnit- the write timeout unit
-
write
public long write(java.nio.ByteBuffer[] srcs, int offset, int length) throws java.io.IOExceptionPerform a blocking, gathering write operation.- Specified by:
writein interfacejava.nio.channels.GatheringByteChannel- Parameters:
srcs- the source buffersoffset- the offset into the destination buffer arraylength- the number of buffers to write from- Returns:
- the number of bytes actually written (will be greater than zero)
- Throws:
java.io.IOException- if an I/O error occurs
-
write
public long write(java.nio.ByteBuffer[] srcs) throws java.io.IOExceptionPerform a blocking, gathering write operation.- Specified by:
writein interfacejava.nio.channels.GatheringByteChannel- Parameters:
srcs- the source buffers- Returns:
- the number of bytes actually written (will be greater than zero)
- Throws:
java.io.IOException- if an I/O error occurs
-
write
public int write(java.nio.ByteBuffer src) throws java.io.IOExceptionPerform a blocking write operation.- Specified by:
writein interfacejava.nio.channels.WritableByteChannel- Parameters:
src- the source buffer- Returns:
- the number of bytes actually written (will be greater than zero)
- Throws:
java.io.IOException- if an I/O error occurs
-
isOpen
public boolean isOpen()
- Specified by:
isOpenin interfacejava.nio.channels.Channel
-
flush
public void flush() throws java.io.IOException- Specified by:
flushin interfacejava.io.Flushable- Throws:
java.io.IOException
-
close
public void close() throws java.io.IOException- Specified by:
closein interfacejava.lang.AutoCloseable- Specified by:
closein interfacejava.nio.channels.Channel- Specified by:
closein interfacejava.io.Closeable- Throws:
java.io.IOException
-
-