public class BufferedChannelInputStream extends InputStream
available()
method can be used to determine whether the next read will or will not block.Constructor and Description |
---|
BufferedChannelInputStream(StreamSourceChannel channel,
int bufferSize)
Construct a new instance.
|
BufferedChannelInputStream(StreamSourceChannel channel,
int bufferSize,
long timeout,
TimeUnit unit)
Construct a new instance.
|
Modifier and Type | Method and Description |
---|---|
int |
available()
Return the number of bytes available to read, or 0 if a subsequent
read() operation would block. |
void |
close()
Close the stream.
|
long |
getReadTimeout(TimeUnit unit)
Get the read timeout.
|
int |
read()
Read a byte, blocking if necessary.
|
int |
read(byte[] b,
int off,
int len)
Read bytes into an array.
|
void |
setReadTimeout(long timeout,
TimeUnit unit)
Set the read timeout.
|
long |
skip(long n)
Skip bytes in the stream.
|
mark, markSupported, read, reset
public BufferedChannelInputStream(StreamSourceChannel channel, int bufferSize)
channel
- the channel to wrapbufferSize
- the size of the internal bufferpublic BufferedChannelInputStream(StreamSourceChannel channel, int bufferSize, long timeout, TimeUnit unit)
channel
- the channel to wrapbufferSize
- the size of the internal buffertimeout
- the initial read timeout, or O for noneunit
- the time unit for the read timeoutpublic long getReadTimeout(TimeUnit unit)
unit
- the time unitpublic void setReadTimeout(long timeout, TimeUnit unit)
timeout
- the read timeout, or 0 for noneunit
- the time unitpublic int read() throws IOException
read
in class InputStream
IOException
- if an I/O error occurspublic int read(byte[] b, int off, int len) throws IOException
read
in class InputStream
b
- the destination arrayoff
- the offset into the array at which bytes should be filledlen
- the number of bytes to fillIOException
- if an I/O error occurspublic long skip(long n) throws IOException
skip
in class InputStream
n
- the number of bytes to skipIOException
- if an I/O error occurspublic int available() throws IOException
read()
operation would block. If
a 0 is returned, the channel's resumeReads()
method may be used
to register for read-readiness.available
in class InputStream
IOException
- if an I/O error occurspublic void close() throws IOException
close
in interface Closeable
close
in interface AutoCloseable
close
in class InputStream
IOException
- if an I/O error occursCopyright © 2016 JBoss by Red Hat. All rights reserved.