public class EndianUtils
extends java.lang.Object
This class provides static utility methods for input/output operations on numbers in Big and Little Endian formats.
Origin of code: Based on the version in POI
Modifier and Type | Class and Description |
---|---|
static class |
EndianUtils.BufferUnderrunException |
Constructor and Description |
---|
EndianUtils() |
Modifier and Type | Method and Description |
---|---|
static int |
getIntBE(byte[] data)
Get a BE int value from the beginning of a byte array
|
static int |
getIntBE(byte[] data,
int offset)
Get a BE int value from a byte array
|
static int |
getIntLE(byte[] data)
Get a LE int value from the beginning of a byte array
|
static int |
getIntLE(byte[] data,
int offset)
Get a LE int value from a byte array
|
static long |
getLongLE(byte[] data,
int offset)
Get a LE long value from a byte array
|
static short |
getShortBE(byte[] data)
Get a BE short value from the beginning of a byte array
|
static short |
getShortBE(byte[] data,
int offset)
Get a BE short value from a byte array
|
static short |
getShortLE(byte[] data)
Get a LE short value from the beginning of a byte array
|
static short |
getShortLE(byte[] data,
int offset)
Get a LE short value from a byte array
|
static short |
getUByte(byte[] data,
int offset)
get the unsigned value of a byte.
|
static long |
getUIntBE(byte[] data)
Get a BE unsigned int value from a byte array
|
static long |
getUIntBE(byte[] data,
int offset)
Get a BE unsigned int value from a byte array
|
static long |
getUIntLE(byte[] data)
Get a LE unsigned int value from a byte array
|
static long |
getUIntLE(byte[] data,
int offset)
Get a LE unsigned int value from a byte array
|
static int |
getUShortBE(byte[] data)
Get a BE unsigned short value from the beginning of a byte array
|
static int |
getUShortBE(byte[] data,
int offset)
Get a BE unsigned short value from a byte array
|
static int |
getUShortLE(byte[] data)
Get a LE unsigned short value from the beginning of a byte array
|
static int |
getUShortLE(byte[] data,
int offset)
Get a LE unsigned short value from a byte array
|
static int |
readIntBE(java.io.InputStream stream)
Get a BE int value from an InputStream
|
static int |
readIntLE(java.io.InputStream stream)
Get a LE int value from an InputStream
|
static long |
readLongBE(java.io.InputStream stream)
Get a NE long value from an InputStream
|
static long |
readLongLE(java.io.InputStream stream)
Get a LE long value from an InputStream
|
static short |
readShortBE(java.io.InputStream stream)
Get a BE short value from an InputStream
|
static short |
readShortLE(java.io.InputStream stream)
Get a LE short value from an InputStream
|
static long |
readUE7(java.io.InputStream stream)
Gets the integer value that is stored in UTF-8 like fashion, in Big Endian
but with the high bit on each number indicating if it continues or not
|
static long |
readUIntBE(java.io.InputStream stream)
Get a BE unsigned int value from an InputStream
|
static long |
readUIntLE(java.io.InputStream stream)
Get a LE unsigned int value from an InputStream
|
static int |
readUShortBE(java.io.InputStream stream) |
static int |
readUShortLE(java.io.InputStream stream) |
static int |
ubyteToInt(byte b)
Convert an 'unsigned' byte to an integer.
|
public static short readShortLE(java.io.InputStream stream) throws java.io.IOException, EndianUtils.BufferUnderrunException
stream
- the InputStream from which the short is to be readjava.io.IOException
- will be propagated back to the callerEndianUtils.BufferUnderrunException
- if the stream cannot provide enough bytespublic static short readShortBE(java.io.InputStream stream) throws java.io.IOException, EndianUtils.BufferUnderrunException
stream
- the InputStream from which the short is to be readjava.io.IOException
- will be propagated back to the callerEndianUtils.BufferUnderrunException
- if the stream cannot provide enough bytespublic static int readUShortLE(java.io.InputStream stream) throws java.io.IOException, EndianUtils.BufferUnderrunException
java.io.IOException
EndianUtils.BufferUnderrunException
public static int readUShortBE(java.io.InputStream stream) throws java.io.IOException, EndianUtils.BufferUnderrunException
java.io.IOException
EndianUtils.BufferUnderrunException
public static long readUIntLE(java.io.InputStream stream) throws java.io.IOException, EndianUtils.BufferUnderrunException
stream
- the InputStream from which the int is to be readjava.io.IOException
- will be propagated back to the callerEndianUtils.BufferUnderrunException
- if the stream cannot provide enough bytespublic static long readUIntBE(java.io.InputStream stream) throws java.io.IOException, EndianUtils.BufferUnderrunException
stream
- the InputStream from which the int is to be readjava.io.IOException
- will be propagated back to the callerEndianUtils.BufferUnderrunException
- if the stream cannot provide enough bytespublic static int readIntLE(java.io.InputStream stream) throws java.io.IOException, EndianUtils.BufferUnderrunException
stream
- the InputStream from which the int is to be readjava.io.IOException
- will be propagated back to the callerEndianUtils.BufferUnderrunException
- if the stream cannot provide enough bytespublic static int readIntBE(java.io.InputStream stream) throws java.io.IOException, EndianUtils.BufferUnderrunException
stream
- the InputStream from which the int is to be readjava.io.IOException
- will be propagated back to the callerEndianUtils.BufferUnderrunException
- if the stream cannot provide enough bytespublic static long readLongLE(java.io.InputStream stream) throws java.io.IOException, EndianUtils.BufferUnderrunException
stream
- the InputStream from which the long is to be readjava.io.IOException
- will be propagated back to the callerEndianUtils.BufferUnderrunException
- if the stream cannot provide enough bytespublic static long readLongBE(java.io.InputStream stream) throws java.io.IOException, EndianUtils.BufferUnderrunException
stream
- the InputStream from which the long is to be readjava.io.IOException
- will be propagated back to the callerEndianUtils.BufferUnderrunException
- if the stream cannot provide enough bytespublic static long readUE7(java.io.InputStream stream) throws java.io.IOException
java.io.IOException
public static short getShortLE(byte[] data)
data
- the byte arraypublic static short getShortLE(byte[] data, int offset)
data
- the byte arrayoffset
- a starting offset into the byte arraypublic static int getUShortLE(byte[] data)
data
- the byte arraypublic static int getUShortLE(byte[] data, int offset)
data
- the byte arrayoffset
- a starting offset into the byte arraypublic static short getShortBE(byte[] data)
data
- the byte arraypublic static short getShortBE(byte[] data, int offset)
data
- the byte arrayoffset
- a starting offset into the byte arraypublic static int getUShortBE(byte[] data)
data
- the byte arraypublic static int getUShortBE(byte[] data, int offset)
data
- the byte arrayoffset
- a starting offset into the byte arraypublic static int getIntLE(byte[] data)
data
- the byte arraypublic static int getIntLE(byte[] data, int offset)
data
- the byte arrayoffset
- a starting offset into the byte arraypublic static int getIntBE(byte[] data)
data
- the byte arraypublic static int getIntBE(byte[] data, int offset)
data
- the byte arrayoffset
- a starting offset into the byte arraypublic static long getUIntLE(byte[] data)
data
- the byte arraypublic static long getUIntLE(byte[] data, int offset)
data
- the byte arrayoffset
- a starting offset into the byte arraypublic static long getUIntBE(byte[] data)
data
- the byte arraypublic static long getUIntBE(byte[] data, int offset)
data
- the byte arrayoffset
- a starting offset into the byte arraypublic static long getLongLE(byte[] data, int offset)
data
- the byte arrayoffset
- a starting offset into the byte arraypublic static int ubyteToInt(byte b)
b
- Description of the Parameterpublic static short getUByte(byte[] data, int offset)
data
- the byte array.offset
- a starting offset into the byte array.Copyright © 2010 - 2020 Adobe. All Rights Reserved