public final class ReadTimeoutStreamSourceChannel extends DelegatingStreamSourceChannel<ReadTimeoutStreamSourceChannel>
Options.READ_TIMEOUT
closeSetter, delegate, readSetter
EMPTY
Constructor and Description |
---|
ReadTimeoutStreamSourceChannel(StreamSourceChannel delegate) |
Modifier and Type | Method and Description |
---|---|
void |
close()
Close this channel.
|
int |
read(ByteBuffer dst) |
long |
read(ByteBuffer[] dsts) |
long |
read(ByteBuffer[] dsts,
int offset,
int length) |
<T> T |
setOption(Option<T> option,
T value)
Set an option for this channel.
|
void |
shutdownReads()
Places this readable channel at "end of stream".
|
long |
transferTo(long count,
ByteBuffer throughBuffer,
StreamSinkChannel target)
Transfers bytes into the given channel target.
|
long |
transferTo(long position,
long count,
FileChannel target)
Transfers bytes into the given file from this channel.
|
awaitReadable, awaitReadable, getCloseSetter, getIoThread, getOption, getReadSetter, getReadThread, getWorker, isOpen, isReadResumed, resumeReads, supportsOption, suspendReads, wakeupReads
public ReadTimeoutStreamSourceChannel(StreamSourceChannel delegate)
delegate
- The underlying channelpublic long transferTo(long position, long count, FileChannel target) throws IOException
StreamSourceChannel
FileChannel.transferFrom(ReadableByteChannel, long, long)
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.
transferTo
in interface StreamSourceChannel
transferTo
in class DelegatingStreamSourceChannel<ReadTimeoutStreamSourceChannel>
position
- the position within the file from which the transfer is to begincount
- the number of bytes to be transferredtarget
- the file to write toIOException
- if an I/O error occurspublic long transferTo(long count, ByteBuffer throughBuffer, StreamSinkChannel target) throws IOException
StreamSourceChannel
throughBuffer
parameter's buffer
space. On entry, throughBuffer
will be cleared. On exit, the buffer will be
flipped for emptying, and may possibly 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 this channel which must
be written to target
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.
Note that the return value is the amount of data that was actually transferred to the StreamSinkChannel
.
The actual amount of data read could be larger than this, and can be calculated by adding the return value and
the amount of data left in throughBuffer
.
transferTo
in interface StreamSourceChannel
transferTo
in class DelegatingStreamSourceChannel<ReadTimeoutStreamSourceChannel>
count
- the number of bytes to be transferredthroughBuffer
- the buffer to copy through.target
- the destination to write toIOException
- if an I/O error occurspublic long read(ByteBuffer[] dsts, int offset, int length) throws IOException
read
in interface ScatteringByteChannel
read
in class DelegatingStreamSourceChannel<ReadTimeoutStreamSourceChannel>
IOException
public long read(ByteBuffer[] dsts) throws IOException
read
in interface ScatteringByteChannel
read
in class DelegatingStreamSourceChannel<ReadTimeoutStreamSourceChannel>
IOException
public int read(ByteBuffer dst) throws IOException
read
in interface ReadableByteChannel
read
in class DelegatingStreamSourceChannel<ReadTimeoutStreamSourceChannel>
IOException
public <T> T setOption(Option<T> option, T value) throws IllegalArgumentException, IOException
Configurable
setOption
in interface Configurable
setOption
in class DelegatingStreamSourceChannel<ReadTimeoutStreamSourceChannel>
T
- the type of the option valueoption
- the option to setvalue
- the value of the option to setIllegalArgumentException
- if the value is not acceptable for this optionIOException
- if an I/O error occurred when modifying the optionpublic void shutdownReads() throws IOException
SuspendableReadChannel
CloseableChannel.close()
to be called automatically.shutdownReads
in interface SuspendableReadChannel
shutdownReads
in class DelegatingStreamSourceChannel<ReadTimeoutStreamSourceChannel>
IOException
- if an I/O error occurspublic void close() throws IOException
CloseableChannel
close
in interface Closeable
close
in interface AutoCloseable
close
in interface Channel
close
in interface InterruptibleChannel
close
in interface CloseableChannel
close
in class DelegatingStreamSourceChannel<ReadTimeoutStreamSourceChannel>
IOException
- if the close failedCopyright © 2016 JBoss by Red Hat. All rights reserved.