Package com.tccc.kos.commons.util
Interface ByteOrderInput
- All Known Implementing Classes:
BinaryMsg
,ByteOrderInputStream
public interface ByteOrderInput
Interface for operation supported by ByteOrderInputStream. Useful in that
other objects can implement this interface and act as a facade over top of
ByteOrderInputStream and ensure things match up.
- Since:
- 1.0
- Version:
- 2022-09-21
-
Method Summary
Modifier and TypeMethodDescriptionint
read
(byte[] b) Read data into the byte array.int
read
(byte[] b, int off, int len) Read the specified number of bytes of data into the array starting at the specified offset.boolean
Read the next byte of input as a boolean value.byte
readByte()
Return the next available byte.Read a C string from input, terminated by a null byte.readCString
(int len) Read a C string from input, terminated by a null byte and padded up to the specified size.double
Read the next eight bytes as a double.Read a C string from input, terminated by a null byte and then process it for escaped UTF-8 characters.float
Read the next four bytes as a float.void
readFully
(byte[] b) Read data into the byte array and only return if the array is full or there is an EOF in the data.int
readInt()
Return the next four bytes as an int.long
readLong()
Return the next eight bytes as a long.short
Return the next two bytes as a signed short.Read all remaining input as a string.int
Return the next byte as an unsigned byte.int
Return the next two bytes as an unsigned short.int
skipBytes
(int n) Skip the specified number of bytes of input.
-
Method Details
-
read
Read data into the byte array. This is not guaranteed to fill the array.- Parameters:
b
- the byte array to read into- Returns:
- the actual number of bytes read
- Throws:
IOException
-
read
Read the specified number of bytes of data into the array starting at the specified offset.- Parameters:
b
- the array to read data intooff
- the starting offsetlen
- the number of bytes to read- Returns:
- the actual number of bytes read
- Throws:
IOException
-
readFully
Read data into the byte array and only return if the array is full or there is an EOF in the data.- Parameters:
b
- the array to read into- Throws:
IOException
- if there is an underlying exceptionEOFException
- if EOF is reached
-
skipBytes
Skip the specified number of bytes of input. Returns the total number of bytes skipped.- Parameters:
n
- the number of bytes to skip- Returns:
- the number of byte skipped
- Throws:
IOException
- if there is an underlying exception
-
readBoolean
Read the next byte of input as a boolean value.- Returns:
- the boolean value
- Throws:
IOException
- if there is an underlying exception or EOF
-
readByte
Return the next available byte.- Returns:
- the byte value
- Throws:
IOException
- if there is an underlying exception or EOF
-
readUnsignedByte
Return the next byte as an unsigned byte.- Returns:
- the unsigned byte value
- Throws:
IOException
- if there is an underlying exception or EOF
-
readShort
Return the next two bytes as a signed short.- Returns:
- the short value
- Throws:
IOException
- if there is an underlying exception or EOF
-
readUnsignedShort
Return the next two bytes as an unsigned short.- Returns:
- the unsigned short value
- Throws:
IOException
- if there is an underlying exception or EOF
-
readInt
Return the next four bytes as an int.- Returns:
- the int value
- Throws:
IOException
- if there is an underlying exception or EOF
-
readLong
Return the next eight bytes as a long.- Returns:
- the long value
- Throws:
IOException
- if there is an underlying exception or EOF
-
readFloat
Read the next four bytes as a float.- Returns:
- the float value
- Throws:
IOException
- if there is an underlying exception or EOF
-
readDouble
Read the next eight bytes as a double.- Returns:
- the double value
- Throws:
IOException
- if there is an underlying exception or EOF
-
readCString
Read a C string from input, terminated by a null byte.- Returns:
- the C string converted to a string
- Throws:
IOException
- if there is an underlying exception or EOF
-
readEscapedCString
Read a C string from input, terminated by a null byte and then process it for escaped UTF-8 characters.- Returns:
- the converted string
- Throws:
IOException
- if there is an underlying exception or EOF
-
readCString
Read a C string from input, terminated by a null byte and padded up to the specified size.- Returns:
- the C string converted to a string
- Throws:
IOException
- if there is an underlying exception or EOF
-
readString
Read all remaining input as a string. This assumes the data in the buffer is not null terminated as a normal C string.- Returns:
- the remaining bytes converted to a string
- Throws:
IOException
- if there is an underlying exception or EOF
-