DataInput which wraps a ByteInput. This implementation maintains
an internal buffer.
| Modifier and Type | Field and Description |
|---|---|
| protected final byte[] | buffer
The internal buffer. |
| protected int | limit
The buffer limit. |
| protected int | position
The buffer position. |
| Access | Constructor and Description |
|---|---|
| public | SimpleDataInput(int
the internal buffer size to use bufferSize)Construct a new instance which wraps nothing. |
| public | SimpleDataInput(int
the internal buffer size to use bufferSize, ByteInput the byte input to initially wrap byteInput)Construct a new instance. |
| public |
| Modifier and Type | Method and Description |
|---|---|
| public int | available()
Overrides org. Implements org. |
| public void | close()
Overrides org. Implements java. |
| private static EOFException | |
| protected void | |
| public int | read()
Overrides org. Implements org. |
| public int | read(final byte[]
the destination array b)Overrides org. Implements org. |
| public int | read(final byte[]
the destination array b, final int the offset into the array into which data should be read off, final int the number of bytes to attempt to fill in the destination array len)Overrides org. Implements org. |
| public boolean | readBoolean()
Implements java. true if that byte is nonzero,
false if that byte is zero.
|
| public byte | |
| public char | |
| public double | readDouble()
Implements java. double value.
|
| public float | readFloat()
Implements java. float value.
|
| public void | readFully(final byte[]
the buffer into which the data is read. b)Implements java. b.
|
| public void | readFully(final 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 | |
| protected int | |
| public String | |
| public long | |
| protected long | |
| public short | |
| public int | readUnsignedByte()
Implements java. int, and returns
the result, which is therefore in the range
0
through 255.
|
| protected int | |
| public int | readUnsignedShort()
Implements java. int value in the range 0
through 65535.
|
| public String | readUTF()
Implements java. |
| public long | skip(final long
the number of bytes to attempt to skip n)Overrides org. Implements org. n bytes of data from this input stream.
|
| public int | skipBytes(final int
the number of bytes to be skipped. n)Implements java. n bytes
of data from the input
stream, discarding the skipped bytes.
|
| protected void |
| buffer | back to summary |
|---|---|
| protected final byte[] buffer The internal buffer. | |
| limit | back to summary |
|---|---|
| protected int limit The buffer limit. | |
| position | back to summary |
|---|---|
| protected int position The buffer position. | |
| SimpleDataInput | back to summary |
|---|---|
| public SimpleDataInput(int bufferSize) Construct a new instance which wraps nothing.
| |
| SimpleDataInput | back to summary |
|---|---|
| public SimpleDataInput(int bufferSize, ByteInput byteInput) Construct a new instance.
| |
| SimpleDataInput | back to summary |
|---|---|
| public SimpleDataInput(final ByteInput byteInput) Construct a new instance. A default buffer size is used.
| |
| available | back to summary |
|---|---|
| public int available() throws IOException Overrides org. Implements org. Doc from org. Returns an estimate of the number of bytes that can be read (or skipped over) from this input stream without blocking by the next invocation of a method for this input stream.
| |
| close | back to summary |
|---|---|
| public void close() throws IOException Overrides org. Implements java. Doc from org. Closes this stream and releases any system resources associated with it. If the stream is already closed then invoking this method has no effect. As noted in
| |
| eofOnRead | back to summary |
|---|---|
| private static EOFException eofOnRead() | |
| finish | back to summary |
|---|---|
| protected void finish() throws IOException Finish reading from the current input. The internal buffer is discarded, not flushed.
| |
| read | back to summary |
|---|---|
| public int read() throws IOException Overrides org. Implements org. Doc from org. Reads the next byte of data from the input stream. If no byte is available because the end of the stream has been reached, the value -1 is returned. This method blocks until input data is available, the end of the stream is detected, or an exception is thrown.
| |
| read | back to summary |
|---|---|
| public int read(final byte[] b) throws IOException Overrides org. Implements org. Doc from org. Read some bytes from the input stream into the given array. Returns the number of bytes actually read (possibly zero), or -1 if the end of stream has been reached.
| |
| read | back to summary |
|---|---|
| public int read(final byte[] b, final int off, final int len) throws IOException Overrides org. Implements org. Doc from org. Read some bytes from the input stream into the given array. Returns the number of bytes actually read (possibly zero), or -1 if the end of stream has been reached.
| |
| 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
| |
| 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(final 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(final 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.
| |
| readIntDirect | back to summary |
|---|---|
| protected int readIntDirect() throws IOException Read an int value.
| |
| 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
| |
| readLongDirect | back to summary |
|---|---|
| protected long readLongDirect() throws IOException | |
| 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
| |
| readUnsignedByteDirect | back to summary |
|---|---|
| protected int readUnsignedByteDirect() throws IOException Read an unsigned byte directly.
| |
| 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
| |
| skip | back to summary |
|---|---|
| public long skip(final long n) throws IOException Overrides org. Implements org. Doc from org. Skips over and discards up to
| |
| skipBytes | back to summary |
|---|---|
| public int skipBytes(final int n) throws IOException Implements java. Doc from java. Makes an attempt to skip over
| |
| start | back to summary |
|---|---|
| protected void start(final ByteInput byteInput) throws IOException Start reading from the given input. The internal buffer is discarded.
| |