InputStream which reads data from a Buffer.
A read operation against this stream will occur at the readerOffset
of its underlying buffer and the readerOffset will increase during
the read operation. Please note that it only reads up to the number of
readable bytes determined at the moment of construction. Therefore,
updating Buffer#writerOffset() will not affect the return
value of available().
This stream implements DataInput for your convenience.
The endianness of the stream is always big endian.
BufferOutputStream
| Modifier and Type | Field and Description |
|---|---|
| private final Buffer | |
| private boolean | |
| private final int | |
| private StringBuilder | |
| private int | |
| private final int |
| Access | Constructor and Description |
|---|---|
| public | BufferInputStream(Send<Buffer>
The buffer which provides the content for this buffer)InputStream.Creates a new stream which reads data from the specified |
| Modifier and Type | Method and Description |
|---|---|
| public int | available()
Overrides java. |
| pack-priv Buffer | |
| private void | |
| private void | |
| public void | close()
Overrides java. Implements java. |
| public void | mark(int
the maximum limit of bytes that can be read before
the mark position becomes invalid. readlimit)Overrides java. |
| public boolean | markSupported()
Overrides java. mark and
reset methods.
|
| public int | read()
Implements abstract java. |
| public int | read(byte[]
the buffer into which the data is read. b, int the start offset in array off, int b
at which the data is written.the maximum number of bytes to read. len)Overrides java. len bytes of data from the input stream into
an array of bytes.
|
| public boolean | readBoolean()
Implements java. true if that byte is nonzero,
false if that byte is zero.
|
| public byte | |
| public int | |
| public char | |
| public double | readDouble()
Implements java. double value.
|
| public float | readFloat()
Implements java. float value.
|
| public void | readFully(byte[]
the buffer into which the data is read. b)Implements java. b.
|
| public void | readFully(byte[]
the buffer into which the data is read. b, int an int specifying the offset in the data array off, int b.an int specifying the number of bytes to read. len)Implements java. len
bytes from
an input stream.
|
| public int | |
| public String | |
| public long | |
| public short | |
| public int | readUnsignedByte()
Implements java. int, and returns
the result, which is therefore in the range
0
through 255.
|
| public int | readUnsignedShort()
Implements java. int value in the range 0
through 65535.
|
| public String | readUTF()
Implements java. |
| public void | reset()
Overrides java. mark method was last called on this input stream.
|
| public long | skip(long
the number of bytes to be skipped. n)Overrides java. n bytes of data from this input
stream.
|
| public int | skipBytes(int
the number of bytes to be skipped. n)Implements java. n bytes
of data from the input
stream, discarding the skipped bytes.
|
| buffer | back to summary |
|---|---|
| private final Buffer buffer | |
| closed | back to summary |
|---|---|
| private boolean closed | |
| endIndex | back to summary |
|---|---|
| private final int endIndex | |
| lineBuf | back to summary |
|---|---|
| private StringBuilder lineBuf | |
| markReaderOffset | back to summary |
|---|---|
| private int markReaderOffset | |
| startIndex | back to summary |
|---|---|
| private final int startIndex | |
| BufferInputStream | back to summary |
|---|---|
| public BufferInputStream(Send<Buffer> buffer) Creates a new stream which reads data from the specified
When this
| |
| available | back to summary |
|---|---|
| public int available() throws IOException Overrides java. Doc from java. Returns an estimate of the number of bytes that can be read (or skipped over) from this input stream without blocking, which may be 0, or 0 when end of stream is detected. The read might be on the same thread or another thread. A single read or skip of this many bytes will not block, but may read or skip fewer bytes. Note that while some implementations of A subclass's implementation of this method may choose to throw an
| |
| buffer | back to summary |
|---|---|
| pack-priv Buffer buffer() Expose the internally owned buffer. Use only for testing purpose.
| |
| checkAvailable | back to summary |
|---|---|
| private void checkAvailable(int fieldSize) throws IOException | |
| checkOpen | back to summary |
|---|---|
| private void checkOpen() throws IOException | |
| close | back to summary |
|---|---|
| public void close() throws IOException Overrides java. Implements java. Doc from java. Closes this input stream and releases any system resources associated with the stream.
| |
| mark | back to summary |
|---|---|
| public void mark(int readlimit) Overrides java. Doc from java. Marks the current position in this input stream. A subsequent call to
the The The general contract of Marking a closed stream should not have any effect on the stream.
| |
| markSupported | back to summary |
|---|---|
| public boolean markSupported() Overrides java. Doc from java. Tests if this input stream supports the
| |
| read | back to summary |
|---|---|
| public int read() throws IOException Implements abstract java. Doc from java. Reads the next byte of data from the input stream. The value byte is
returned as an
| |
| read | back to summary |
|---|---|
| public int read(byte[] b, int off, int len) throws IOException Overrides java. Doc from java. Reads up to This method blocks until input data is available, end of file is detected, or an exception is thrown. If The first byte read is stored into element In every case, elements
| |
| readBoolean | back to summary |
|---|---|
| public boolean readBoolean() throws IOException Implements java. Doc from java. Reads one input byte and returns
| |
| readByte | back to summary |
|---|---|
| public byte readByte() throws IOException Implements java. Doc from java. Reads and returns one input byte.
The byte is treated as a signed value in
the range
| |
| readBytes | back to summary |
|---|---|
| public int readBytes() Returns the number of read bytes by this stream so far. | |
| readChar | back to summary |
|---|---|
| public char readChar() throws IOException Implements java. Doc from java. Reads two input bytes and returns a
This method
is suitable for reading bytes written by
the writeChar method of interface
DataOutput.
| |
| readDouble | back to summary |
|---|---|
| public double readDouble() throws IOException Implements java. Doc from java. Reads eight input bytes and returns
a
| |
| readFloat | back to summary |
|---|---|
| public float readFloat() throws IOException Implements java. Doc from java. Reads four input bytes and returns
a
| |
| readFully | back to summary |
|---|---|
| public void readFully(byte[] b) throws IOException Implements java. Doc from java. Reads some bytes from an input
stream and stores them into the buffer
array This method blocks until one of the following conditions occurs:
If
| |
| readFully | back to summary |
|---|---|
| public void readFully(byte[] b, int off, int len) throws IOException Implements java. Doc from java. Reads This method blocks until one of the following conditions occurs:
If
| |
| readInt | back to summary |
|---|---|
| public int readInt() throws IOException Implements java. Doc from java. Reads four input bytes and returns an
This method is suitable
for reading bytes written by the writeInt
method of interface DataOutput.
| |
| readLine | back to summary |
|---|---|
| public String readLine() throws IOException Implements java. Doc from java. Reads the next line of text from the input stream.
It reads successive bytes, converting
each byte separately into a character,
until it encounters a line terminator or
end of
file; the characters read are then
returned as a
If end of file is encountered
before even one byte can be read, then
| |
| readLong | back to summary |
|---|---|
| public long readLong() throws IOException Implements java. Doc from java. Reads eight input bytes and returns
a
This method is suitable
for reading bytes written by the
| |
| readShort | back to summary |
|---|---|
| public short readShort() throws IOException Implements java. Doc from java. Reads two input bytes and returns
a
This method
is suitable for reading the bytes written
by the writeShort method of
interface DataOutput.
| |
| readUnsignedByte | back to summary |
|---|---|
| public int readUnsignedByte() throws IOException Implements java. Doc from java. Reads one input byte, zero-extends
it to type
| |
| readUnsignedShort | back to summary |
|---|---|
| public int readUnsignedShort() throws IOException Implements java. Doc from java. Reads two input bytes and returns
an
This method is suitable for reading the bytes
written by the writeShort method
of interface DataOutput if
the argument to writeShort
was intended to be a value in the range
0 through 65535.
| |
| readUTF | back to summary |
|---|---|
| public String readUTF() throws IOException Implements java. Doc from java. Reads in a string that has been encoded using a
modified UTF-8
format.
The general contract of
First, two bytes are read and used to
construct an unsigned 16-bit integer in
exactly the manner of the
If the first byte of a group
matches the bit pattern
If the first byte
of a group matches the bit pattern
If the first byte of a group
matches the bit pattern 1110xxxx,
then the group consists of that byte a
and two more bytes b and c.
If there is no byte c (because
byte a was one of the last
two of the bytes to be read), or either
byte b or byte c
does not match the bit pattern 10xxxxxx,
then a UTFDataFormatException
is thrown. Otherwise, the group is converted
to the character:
If the first byte of a group matches the
pattern 1111xxxx or the pattern
10xxxxxx, then a UTFDataFormatException
is thrown.
If end of file is encountered
at any time during this entire process,
then an
After every group has been converted to
a character by this process, the characters
are gathered, in the same order in which
their corresponding groups were read from
the input stream, to form a
The
| |
| reset | back to summary |
|---|---|
| public void reset() throws IOException Overrides java. Doc from java. Repositions this stream to the position at the time the
The general contract of
| |
| skip | back to summary |
|---|---|
| public long skip(long n) throws IOException Overrides java. Doc from java. Skips over and discards
| |
| skipBytes | back to summary |
|---|---|
| public int skipBytes(int n) throws IOException Implements java. Doc from java. Makes an attempt to skip over
| |