Class LittleEndianDataInputStream
java.lang.Object
net.codecrete.windowsapi.winmd.LittleEndianDataInputStream
A data input stream to read primitive Java data types
in little-endian organization from an underlying input stream.
Similar to DataInputStream but uses little-endian
instead of big-endian byte organization.
-
Constructor Summary
ConstructorsConstructorDescriptionCreates an instance using the specified underlying InputStream. -
Method Summary
Modifier and TypeMethodDescriptionlongReturns the current offset into the stream.final bytereadByte()Reads a bytefinal voidreadFully(byte[] b) Reads data from the input.final voidreadFully(byte[] b, int off, int len) Reads data from the input.final intreadInt()Reads a signed 32-bit integer number.final longreadLong()Reads a signed 64-bit integer number.final intReads an unsigned 16-bit integer number.voidskipNBytes(int n) Skips several bytes without further processing.voidskipTo(int offset) Skips to the specified offset.
-
Constructor Details
-
LittleEndianDataInputStream
Creates an instance using the specified underlying InputStream.- Parameters:
in- the specified input stream
-
-
Method Details
-
getOffset
public long getOffset()Returns the current offset into the stream.- Returns:
- offset, in bytes
-
readFully
Reads data from the input.- Parameters:
b- the buffer into which the data is read.- Throws:
EOFException- if this input stream reaches the end before reading all the bytes.IOException- if another error occurs during reading
-
readFully
Reads data from the input.- Parameters:
b- the buffer into which the data is read.off- the start offset in the data arrayb.len- the number of bytes to read.- Throws:
EOFException- if this input stream reaches the end before reading all the bytes.IOException- if another error occurs during reading
-
skipNBytes
Skips several bytes without further processing.- Parameters:
n- the number of bytes to skip- Throws:
IOException- thrown if an IO error occurs
-
skipTo
Skips to the specified offset.- Parameters:
offset- number of bytes into the steam- Throws:
EOFException- if the offset is after the end of the streamIOException- if an I/O error occurs
-
readByte
Reads a byte- Returns:
- the next byte of this input stream as a signed 8-bit
byte. - Throws:
EOFException- if this input stream has reached the end.IOException- if any other I/O error occurs.
-
readUnsignedShort
Reads an unsigned 16-bit integer number.- Returns:
- the next two bytes of this input stream, interpreted as an unsigned 16-bit integer.
- Throws:
EOFException- if this input stream has reached the end.IOException- if any other I/O error occurs.
-
readInt
Reads a signed 32-bit integer number.- Returns:
- the next four bytes of this input stream, interpreted as an
int. - Throws:
EOFException- if this input stream has reached the end.IOException- if any other I/O error occurs.
-
readLong
Reads a signed 64-bit integer number.- Returns:
- the next 8 bytes of this input stream, interpreted as an
int. - Throws:
EOFException- if this input stream has reached the end.IOException- if any other I/O error occurs.
-