public interface StreamSinkChannel extends WritableByteChannel, GatheringByteChannel, SuspendableWriteChannel
EMPTY
Modifier and Type | Method and Description |
---|---|
ChannelListener.Setter<? extends StreamSinkChannel> |
getCloseSetter()
Get the setter which can be used to change the close listener for this channel.
|
ChannelListener.Setter<? extends StreamSinkChannel> |
getWriteSetter()
Get the setter which can be used to change the write listener for this channel.
|
long |
transferFrom(FileChannel src,
long position,
long count)
Transfer bytes into this channel from the given file.
|
long |
transferFrom(StreamSourceChannel source,
long count,
ByteBuffer throughBuffer)
Transfers bytes from the given channel source.
|
int |
writeFinal(ByteBuffer src)
Writes some data to the channel, with the same semantics as
WritableByteChannel.write(java.nio.ByteBuffer) . |
long |
writeFinal(ByteBuffer[] srcs)
Writes some data to the channel, with the same semantics as
GatheringByteChannel.write(java.nio.ByteBuffer[]) . |
long |
writeFinal(ByteBuffer[] srcs,
int offset,
int length)
Writes some data to the channel, with the same semantics as
GatheringByteChannel.write(java.nio.ByteBuffer[], int, int) . |
write, write
write
awaitWritable, awaitWritable, close, flush, getWriteThread, isOpen, isWriteResumed, resumeWrites, shutdownWrites, suspendWrites, wakeupWrites
getIoThread, getWorker
getOption, setOption, supportsOption
long transferFrom(FileChannel src, long position, long count) throws IOException
FileChannel.transferTo(long, long, WritableByteChannel)
may provide a performance advantage on some platforms.
If the current thread is interrupted when this method is called, it may throw a InterruptedIOException
;
however, if this exception is thrown, the InterruptedIOException.bytesTransferred
field is
guaranteed to be 0.
src
- the file to read fromposition
- the position within the file from which the transfer is to begincount
- the number of bytes to be transferredIOException
- if an I/O error occurslong transferFrom(StreamSourceChannel source, long count, ByteBuffer throughBuffer) throws IOException
throughBuffer
parameter's buffer
space. On entry, throughBuffer
will be cleared. On exit, the buffer will be
flipped for emptying, and may be empty or may contain data. If this method returns a value less than
count
, then the remaining data in throughBuffer
may contain data read from source
which must
be written to this channel to complete the operation. Note that using a direct buffer may provide an
intermediate performance gain on platforms without zero-copy facilities.
If the current thread is interrupted when this method is called, it may throw a InterruptedIOException
;
however, if this exception is thrown, the InterruptedIOException.bytesTransferred
field is
guaranteed to be 0.
source
- the source to read fromcount
- the number of bytes to be transferredthroughBuffer
- the buffer to copy through.IOException
- if an I/O error occursChannelListener.Setter<? extends StreamSinkChannel> getWriteSetter()
getWriteSetter
in interface SuspendableWriteChannel
ChannelListener.Setter<? extends StreamSinkChannel> getCloseSetter()
getCloseSetter
in interface CloseableChannel
getCloseSetter
in interface SuspendableWriteChannel
int writeFinal(ByteBuffer src) throws IOException
WritableByteChannel.write(java.nio.ByteBuffer)
. If all the data is written
out then the channel will have its writes shutdown. Semantically this
method is equivalent to:
int rem = src.remaining();
int written = channel.write(src);
if(written == rem) {
channel.shutdownWrites()
}
If an exception is thrown the caller is still responsible for closing the channel.src
- The data to writeIOException
WritableByteChannel.write(java.nio.ByteBuffer)
,
SuspendableWriteChannel.shutdownWrites()
long writeFinal(ByteBuffer[] srcs, int offset, int length) throws IOException
GatheringByteChannel.write(java.nio.ByteBuffer[], int, int)
. If all the data is written
out then the channel will have its writes shutdown.
If an exception is thrown the caller is still responsible for closing the channel.srcs
- The buffers from which bytes are to be retrievedoffset
- The offset within the buffer array of the first buffer from
which bytes are to be retrieved; must be non-negative and no
larger than srcs.lengthlength
- The maximum number of buffers to be accessed; must be
non-negative and no larger than
srcs.length - offsetIOException
GatheringByteChannel.write(java.nio.ByteBuffer[], int, int)
,
SuspendableWriteChannel.shutdownWrites()
long writeFinal(ByteBuffer[] srcs) throws IOException
GatheringByteChannel.write(java.nio.ByteBuffer[])
. If all the data is written
out then the channel will have its writes shutdown.
If an exception is thrown the caller is still responsible for closing the channel.srcs
- The buffers from which bytes are to be retrievedIOException
GatheringByteChannel.write(java.nio.ByteBuffer[])
,
SuspendableWriteChannel.shutdownWrites()
Copyright © 2021 JBoss by Red Hat. All rights reserved.