public class ChannelBufferInputStream extends InputStreamChannel
Note that the close() method of this class does not closing the underlying channel.
| Modifier and Type | Field and Description |
|---|---|
protected ByteBuffer |
buffer |
static int |
DEFAULT_BUFFER_SIZE |
channel, PARK_NANOS, PARK_NANOS_MAX, parkedThread| Constructor and Description |
|---|
ChannelBufferInputStream(ReadableByteChannel channel) |
ChannelBufferInputStream(ReadableByteChannel channel,
int bufferSize) |
| Modifier and Type | Method and Description |
|---|---|
protected ByteBuffer |
allocateBuffer(int bufferSize) |
int |
available() |
void |
close() |
boolean |
isOpen() |
int |
read() |
int |
read(byte[] buf,
int off,
int len) |
int |
read(ByteBuffer dst) |
int |
readInt()
Reads four input bytes and returns an
int value. |
getParkedThread, getUnderlyingChannel, readBuffered, readFrame, readFrameFragment, readIntoBuffer, readIntoBufferNonBlocking, refillBuffer, resetAndCopyLeftOverBytesmark, markSupported, read, reset, skipprotected final ByteBuffer buffer
public static final int DEFAULT_BUFFER_SIZE
public ChannelBufferInputStream(ReadableByteChannel channel) throws IOException
IOExceptionpublic ChannelBufferInputStream(ReadableByteChannel channel, int bufferSize) throws IOException
IOExceptionprotected ByteBuffer allocateBuffer(int bufferSize)
public final int read()
throws IOException
read in class InputStreamIOExceptionpublic final int read(byte[] buf,
int off,
int len)
throws IOException
read in class InputStreamIOExceptionpublic final int read(ByteBuffer dst) throws IOException
read in interface ReadableByteChannelread in class InputStreamChannelIOExceptionpublic final int readInt()
throws IOException
int value. Let
a-d be the first through fourth bytes read. The value returned
is:
(((a & 0xff) << 24) | ((b & 0xff) << 16) |
((c & 0xff) << 8) | (d & 0xff))
This method is suitable for reading bytes written by the
writeInt method of interface DataOutput.readInt in class InputStreamChannelint value read.EOFException - if this stream reaches the end before reading all the bytes.IOException - if an I/O error occurs.public final int available()
throws IOException
available in class InputStreamIOExceptionpublic final boolean isOpen()
public void close()
throws IOException
close in interface Closeableclose in interface AutoCloseableclose in interface Channelclose in class InputStreamIOExceptionCopyright © 2010-2015 Pivotal Software, Inc. All rights reserved.