|
XNIO API 3.0.4.GA | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object java.io.InputStream org.xnio.streams.BufferedChannelInputStream
public class BufferedChannelInputStream
An input stream which reads from a stream source channel with a buffer. In addition, the
available()
method can be used to determine whether the next read will or will not block.
Constructor Summary | |
---|---|
BufferedChannelInputStream(StreamSourceChannel channel,
int bufferSize)
Construct a new instance. |
|
BufferedChannelInputStream(StreamSourceChannel channel,
int bufferSize,
long timeout,
TimeUnit unit)
Construct a new instance. |
Method Summary | |
---|---|
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. |
Methods inherited from class java.io.InputStream |
---|
mark, markSupported, read, reset |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
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 timeoutMethod Detail |
---|
public long getReadTimeout(TimeUnit unit)
unit
- the time unit
public 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 fill
IOException
- if an I/O error occurspublic long skip(long n) throws IOException
skip
in class InputStream
n
- the number of bytes to skip
IOException
- 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 class InputStream
IOException
- if an I/O error occurs
|
XNIO API 3.0.4.GA | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |