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 ByteOrder
DEFAULT_BYTE_ORDER
Default 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 void
close()
Close the byte readerByteOrder
getByteOrder()
Get the byte orderbyte[]
getBytes()
Get the bytesInputStream
getInputStream()
Get the output streamint
getNextByte()
Get the next byte to be readbyte
readByte()
Read a bytebyte[]
readBytes(int num)
Read the number of bytesdouble
readDouble()
Read a doubleint
readInt()
Read an integerString
readString(int num)
Read a String from the provided number of byteslong
readUnsignedInt()
Read an unsigned integervoid
setByteOrder(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 IOException
Read the number of bytes- Parameters:
num
- number of bytes- Returns:
- bytes
- Throws:
IOException
- upon error
-
readByte
public byte readByte() throws IOException
Read a byte- Returns:
- byte
- Throws:
IOException
- upon error
-
readInt
public int readInt() throws IOException
Read an integer- Returns:
- integer
- Throws:
IOException
- upon error
-
readUnsignedInt
public long readUnsignedInt() throws IOException
Read an unsigned integer- Returns:
- unsigned integer
- Throws:
IOException
- upon error
-
readDouble
public double readDouble() throws IOException
Read a double- Returns:
- double
- Throws:
IOException
- upon error
-
-