@Beta @GwtIncompatible public final class LittleEndianDataInputStream extends java.io.FilterInputStream implements java.io.DataInput
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.
Constructor and Description |
---|
LittleEndianDataInputStream(java.io.InputStream in)
Creates a
LittleEndianDataInputStream that wraps the given stream. |
Modifier and Type | Method and Description |
---|---|
private byte |
readAndCheckByte()
Reads a byte from the input stream checking that the end of file (EOF) has not been
encountered.
|
boolean |
readBoolean() |
byte |
readByte() |
char |
readChar()
Reads a char as specified by
DataInputStream.readChar() , except using little-endian
byte order. |
double |
readDouble()
Reads a
double as specified by DataInputStream.readDouble() , except using
little-endian byte order. |
float |
readFloat()
Reads a
float as specified by DataInputStream.readFloat() , except using
little-endian byte order. |
void |
readFully(byte[] b) |
void |
readFully(byte[] b,
int off,
int len) |
int |
readInt()
Reads an integer as specified by
DataInputStream.readInt() , except using little-endian
byte order. |
java.lang.String |
readLine()
This method will throw an
UnsupportedOperationException . |
long |
readLong()
Reads a
long as specified by DataInputStream.readLong() , except using
little-endian byte order. |
short |
readShort()
Reads a
short as specified by DataInputStream.readShort() , except using
little-endian byte order. |
int |
readUnsignedByte() |
int |
readUnsignedShort()
Reads an unsigned
short as specified by DataInputStream.readUnsignedShort() ,
except using little-endian byte order. |
java.lang.String |
readUTF() |
int |
skipBytes(int n) |
public LittleEndianDataInputStream(java.io.InputStream in)
LittleEndianDataInputStream
that wraps the given stream.in
- the stream to delegate topublic java.lang.String readLine()
UnsupportedOperationException
.readLine
in interface java.io.DataInput
public void readFully(byte[] b) throws java.io.IOException
readFully
in interface java.io.DataInput
java.io.IOException
public void readFully(byte[] b, int off, int len) throws java.io.IOException
readFully
in interface java.io.DataInput
java.io.IOException
public int skipBytes(int n) throws java.io.IOException
skipBytes
in interface java.io.DataInput
java.io.IOException
public int readUnsignedByte() throws java.io.IOException
readUnsignedByte
in interface java.io.DataInput
java.io.IOException
public int readUnsignedShort() throws java.io.IOException
short
as specified by DataInputStream.readUnsignedShort()
,
except using little-endian byte order.readUnsignedShort
in interface java.io.DataInput
java.io.IOException
- if an I/O error occurspublic int readInt() throws java.io.IOException
DataInputStream.readInt()
, except using little-endian
byte order.readInt
in interface java.io.DataInput
int
in little-endian
byte orderjava.io.IOException
- if an I/O error occurspublic long readLong() throws java.io.IOException
long
as specified by DataInputStream.readLong()
, except using
little-endian byte order.readLong
in interface java.io.DataInput
long
in
little-endian byte orderjava.io.IOException
- if an I/O error occurspublic float readFloat() throws java.io.IOException
float
as specified by DataInputStream.readFloat()
, except using
little-endian byte order.readFloat
in interface java.io.DataInput
float
in
little-endian byte orderjava.io.IOException
- if an I/O error occurspublic double readDouble() throws java.io.IOException
double
as specified by DataInputStream.readDouble()
, except using
little-endian byte order.readDouble
in interface java.io.DataInput
double
in
little-endian byte orderjava.io.IOException
- if an I/O error occurspublic java.lang.String readUTF() throws java.io.IOException
readUTF
in interface java.io.DataInput
java.io.IOException
public short readShort() throws java.io.IOException
short
as specified by DataInputStream.readShort()
, except using
little-endian byte order.readShort
in interface java.io.DataInput
short
in little-endian
byte order.java.io.IOException
- if an I/O error occurs.public char readChar() throws java.io.IOException
DataInputStream.readChar()
, except using little-endian
byte order.readChar
in interface java.io.DataInput
char
in little-endian
byte orderjava.io.IOException
- if an I/O error occurspublic byte readByte() throws java.io.IOException
readByte
in interface java.io.DataInput
java.io.IOException
public boolean readBoolean() throws java.io.IOException
readBoolean
in interface java.io.DataInput
java.io.IOException
private byte readAndCheckByte() throws java.io.IOException, java.io.EOFException
java.io.IOException
- if an error is encountered while readingjava.io.EOFException
- if the end of file (EOF) is encountered.