Package mil.nga.sf.util
Class ByteReader
- java.lang.Object
-
- mil.nga.sf.util.ByteReader
-
public class ByteReader extends Object
Read through a byte array- Author:
- osbornb
-
-
Field Summary
Fields Modifier and Type Field Description static ByteOrderDEFAULT_BYTE_ORDERDefault read byte order
-
Constructor Summary
Constructors Constructor Description ByteReader(byte[] bytes)ConstructorByteReader(byte[] bytes, ByteOrder byteOrder)ConstructorByteReader(InputStream inputStream)ConstructorByteReader(InputStream inputStream, ByteOrder byteOrder)Constructor
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidclose()Close the byte readerByteOrdergetByteOrder()Get the byte orderbyte[]getBytes()Get the bytesInputStreamgetInputStream()Get the output streamintgetNextByte()Get the next byte to be readbytereadByte()Read a bytebyte[]readBytes(int num)Read the number of bytesdoublereadDouble()Read a doubleintreadInt()Read an integerStringreadString(int num)Read a String from the provided number of byteslongreadUnsignedInt()Read an unsigned integervoidsetByteOrder(ByteOrder byteOrder)Set the byte order
-
-
-
Field Detail
-
DEFAULT_BYTE_ORDER
public static final ByteOrder DEFAULT_BYTE_ORDER
Default read byte order- Since:
- 2.0.3
-
-
Constructor Detail
-
ByteReader
public ByteReader(byte[] bytes)
Constructor- Parameters:
bytes- bytes
-
ByteReader
public ByteReader(InputStream inputStream)
Constructor- Parameters:
inputStream- input stream- Since:
- 2.0.3
-
ByteReader
public ByteReader(byte[] bytes, ByteOrder byteOrder)Constructor- Parameters:
bytes- bytesbyteOrder- byte order- Since:
- 2.0.3
-
ByteReader
public ByteReader(InputStream inputStream, ByteOrder byteOrder)
Constructor- Parameters:
inputStream- input streambyteOrder- byte order- Since:
- 2.0.3
-
-
Method Detail
-
getBytes
public byte[] getBytes()
Get the bytes- Returns:
- bytes
- Since:
- 2.0.3
-
getInputStream
public InputStream getInputStream()
Get the output stream- Returns:
- output stream
- Since:
- 2.0.3
-
close
public void close()
Close the byte reader- Since:
- 2.0.3
-
getNextByte
public int getNextByte()
Get the next byte to be read- Returns:
- next byte to be read
-
getByteOrder
public ByteOrder getByteOrder()
Get the byte order- Returns:
- byte order
-
setByteOrder
public void setByteOrder(ByteOrder byteOrder)
Set the byte order- Parameters:
byteOrder- byte order
-
readString
public String readString(int num) throws IOException
Read a String from the provided number of bytes- Parameters:
num- number of bytes- Returns:
- String
- Throws:
IOException- upon error
-
readBytes
public byte[] readBytes(int num) throws IOExceptionRead the number of bytes- Parameters:
num- number of bytes- Returns:
- bytes
- Throws:
IOException- upon error
-
readByte
public byte readByte() throws IOExceptionRead a byte- Returns:
- byte
- Throws:
IOException- upon error
-
readInt
public int readInt() throws IOExceptionRead an integer- Returns:
- integer
- Throws:
IOException- upon error
-
readUnsignedInt
public long readUnsignedInt() throws IOExceptionRead an unsigned integer- Returns:
- unsigned integer
- Throws:
IOException- upon error
-
readDouble
public double readDouble() throws IOExceptionRead a double- Returns:
- double
- Throws:
IOException- upon error
-
-