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 java.nio.ByteBuffer |
buffer |
static int |
DEFAULT_BUFFER_SIZE |
bytesRead, channel| Constructor and Description |
|---|
ChannelBufferInputStream(java.nio.channels.ReadableByteChannel channel) |
ChannelBufferInputStream(java.nio.channels.ReadableByteChannel channel,
int bufferSize) |
| Modifier and Type | Method and Description |
|---|---|
protected java.nio.ByteBuffer |
allocateBuffer(int bufferSize) |
int |
available() |
void |
close() |
boolean |
isOpen() |
int |
read() |
int |
read(byte[] buf,
int off,
int len) |
int |
read(java.nio.ByteBuffer dst) |
int |
readInt()
Reads four input bytes and returns an
int value. |
getBytesRead, getParkedThread, getParkNanosMax, getUnderlyingChannel, readBuffered, readFrame, readFrameFragment, readIntoBuffer, readIntoBufferNoWait, refillBuffer, refillBufferBase, resetAndCopyLeftOverBytes, setParkedThreadprotected final java.nio.ByteBuffer buffer
public static final int DEFAULT_BUFFER_SIZE
public ChannelBufferInputStream(java.nio.channels.ReadableByteChannel channel)
throws java.io.IOException
java.io.IOExceptionpublic ChannelBufferInputStream(java.nio.channels.ReadableByteChannel channel,
int bufferSize)
throws java.io.IOException
java.io.IOExceptionprotected java.nio.ByteBuffer allocateBuffer(int bufferSize)
public final int read()
throws java.io.IOException
read in class java.io.InputStreamjava.io.IOExceptionpublic final int read(byte[] buf,
int off,
int len)
throws java.io.IOException
read in class java.io.InputStreamjava.io.IOExceptionpublic final int read(java.nio.ByteBuffer dst)
throws java.io.IOException
read in interface java.nio.channels.ReadableByteChannelread in class InputStreamChanneljava.io.IOExceptionpublic final int readInt()
throws java.io.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.java.io.EOFException - if this stream reaches the end before reading all the bytes.java.io.IOException - if an I/O error occurs.public final int available()
throws java.io.IOException
available in class java.io.InputStreamjava.io.IOExceptionpublic final boolean isOpen()
public void close()
throws java.io.IOException
close in interface java.io.Closeableclose in interface java.lang.AutoCloseableclose in interface java.nio.channels.Channelclose in class java.io.InputStreamjava.io.IOExceptionCopyright © 2010-2015 Pivotal Software, Inc. All rights reserved.