Class LittleEndianInputStream
java.lang.Object
java.io.InputStream
java.io.FilterInputStream
net.simplace.core.io.endian.LittleEndianInputStream
- All Implemented Interfaces:
Closeable, AutoCloseable
Input stream that reads primitive values in little-endian byte order (counterpart of
LittleEndianOutputStream).-
Field Summary
Fields inherited from class FilterInputStream
in -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbooleanbytereadByte(int b) charreadChar()final doublefinal floatintreadInt()longreadLong()shortintintreadUTF()Reads a string in modified UTF-8 with a 2 byte length prefix (big-endian, as written byLittleEndianOutputStream.writeUTF(String)).final intskipBytes(int n) Skips bytes; loops until all bytes are skipped.booleanSkips all bytes up to and including the next ETX character.Methods inherited from class FilterInputStream
available, close, mark, markSupported, read, read, read, reset, skipMethods inherited from class InputStream
nullInputStream, readAllBytes, readNBytes, readNBytes, skipNBytes, transferTo
-
Constructor Details
-
LittleEndianInputStream
- Parameters:
in- the underlying stream
-
-
Method Details
-
readBoolean
- Returns:
trueif the next byte is not 0- Throws:
IOException- at the end of the stream (EOFException) or on read errors
-
skipUntilETX
Skips all bytes up to and including the next ETX character.- Returns:
trueif an ETX was found,falseif the end of the stream was reached- Throws:
IOException- on read errors
-
readByte
- Parameters:
b- not used- Returns:
- the next byte
- Throws:
IOException- at the end of the stream (EOFException) or on read errors
-
readUnsignedByte
- Returns:
- the next byte as unsigned value (0..255)
- Throws:
IOException- at the end of the stream (EOFException) or on read errors
-
readShort
- Returns:
- the next 2 bytes as short (little-endian)
- Throws:
IOException- at the end of the stream (EOFException) or on read errors
-
readUnsignedShort
- Returns:
- the next 2 bytes as unsigned short (little-endian)
- Throws:
IOException- at the end of the stream (EOFException) or on read errors
-
readChar
- Returns:
- the next 2 bytes as char (little-endian)
- Throws:
IOException- at the end of the stream (EOFException) or on read errors
-
readInt
- Returns:
- the next 4 bytes as int (little-endian)
- Throws:
IOException- at the end of the stream (EOFException) or on read errors
-
readLong
- Returns:
- the next 8 bytes as long (little-endian)
- Throws:
IOException- at the end of the stream (EOFException) or on read errors
-
readUTF
Reads a string in modified UTF-8 with a 2 byte length prefix (big-endian, as written byLittleEndianOutputStream.writeUTF(String)).- Returns:
- the string
- Throws:
IOException- at the end of the stream, for malformed data (UTFDataFormatException) or on read errors
-
readDouble
- Returns:
- the next 8 bytes as double (little-endian)
- Throws:
IOException- at the end of the stream (EOFException) or on read errors
-
readFloat
- Returns:
- the next 4 bytes as float (little-endian)
- Throws:
IOException- at the end of the stream (EOFException) or on read errors
-
skipBytes
Skips bytes; loops until all bytes are skipped.- Parameters:
n- number of bytes to skip- Returns:
n- Throws:
IOException- on read errors
-