DataInput that uses little-endian byte ordering for reading short, int, float, double, and long values.Note
This class intentionally violates the specification of its supertype DataInput, which explicitly requires big-endian byte order.
| Access | Constructor and Description |
|---|---|
| public | LittleEndianDataInputStream(InputStream
the stream to delegate to in)Creates a |
| Modifier and Type | Method and Description |
|---|---|
| private byte | Returns: byte read from inputReads a byte from the input stream checking that the end of file (EOF) has not been encountered. |
| public boolean | readBoolean()
Implements java. true if that byte is nonzero,
false if that byte is zero.
|
| public byte | |
| public char | Returns: the next two bytes of the input stream, interpreted as achar in little-endian
byte orderImplements java. DataInputStream#readChar(), except using little-endian
byte order.
|
| public double | Returns: the next eight bytes of the input stream, interpreted as adouble in
little-endian byte orderImplements java. double as specified by DataInputStream#readDouble(), except using
little-endian byte order.
|
| public float | Returns: the next four bytes of the input stream, interpreted as afloat in
little-endian byte orderImplements java. float as specified by DataInputStream#readFloat(), except using
little-endian byte order.
|
| 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 | Returns: the next four bytes of the input stream, interpreted as anint in little-endian
byte orderImplements java. DataInputStream#readInt(), except using little-endian
byte order.
|
| public String | readLine()
Implements java. UnsupportedOperationException.
|
| public long | Returns: the next eight bytes of the input stream, interpreted as along in
little-endian byte orderImplements java. long as specified by DataInputStream#readLong(), except using
little-endian byte order.
|
| public short | Returns: the next two bytes of the input stream, interpreted as ashort in little-endian
byte order.Implements java. short as specified by DataInputStream#readShort(), except using
little-endian byte order.
|
| public int | readUnsignedByte()
Implements java. int, and returns
the result, which is therefore in the range
0
through 255.
|
| public int | Returns: the next two bytes of the input stream, interpreted as an unsigned 16-bit integer in little-endian byte orderImplements java. short as specified by DataInputStream#readUnsignedShort(),
except using little-endian byte order.
|
| public String | readUTF()
Implements java. |
| 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.
|
| LittleEndianDataInputStream | back to summary |
|---|---|
| public LittleEndianDataInputStream(InputStream in) Creates a
| |
| readAndCheckByte | back to summary |
|---|---|
| private byte readAndCheckByte() throws IOException, EOFException Reads a byte from the input stream checking that the end of file (EOF) has not been encountered.
| |
| 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. Reads a char as specified by
| |
| readDouble | back to summary |
|---|---|
| public double readDouble() throws IOException Implements java. Reads a
| |
| readFloat | back to summary |
|---|---|
| public float readFloat() throws IOException Implements java. Reads 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. Reads an integer as specified by
| |
| readLine | back to summary |
|---|---|
| public String readLine() Implements java. This method will throw an
| |
| readLong | back to summary |
|---|---|
| public long readLong() throws IOException Implements java. Reads a
| |
| readShort | back to summary |
|---|---|
| public short readShort() throws IOException Implements java. Reads a
| |
| 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. Reads an unsigned
| |
| 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
| |
| skipBytes | back to summary |
|---|---|
| public int skipBytes(int n) throws IOException Implements java. Doc from java. Makes an attempt to skip over
| |