Constructor and Description |
---|
ByteUtil() |
Modifier and Type | Method and Description |
---|---|
static int |
get1ByteInt(byte[] inBytes,
int inOffset)
Returns a 1-byte int from the given byte array.
|
static int |
get2ByteInt(byte[] inBytes)
Returns a 2-byte int from the given byte array.
|
static int |
get2ByteInt(byte[] inBytes,
ByteOrder inByteOrder)
Returns a 2-byte int from the given byte[].
|
static int |
get2ByteInt(byte[] inBytes,
int inOffset)
Returns a 2-byte int from the given byte array.
|
static int |
get2ByteInt(byte[] inBytes,
int inOffset,
ByteOrder inByteOrder)
Returns a 2-byte int from the given byte[].
|
static int |
get2ByteInt(ByteSource inByteSource,
ByteOrder inByteOrder)
Returns a 2-byte int from the current position of the specified ByteSource.
|
static int |
get2ByteInt(InputStream inStream)
Returns a 2-byte int from the given InputStream.
|
static int |
get2ByteInt(InputStream inStream,
ByteOrder inByteOrder)
Returns a 2-byte int from the given InputStream.
|
static int |
get2ByteInt(RandomAccessFile inRandomAccessFile,
ByteOrder inByteOrder)
Returns a 2-byte int from the current position of the specified RandomAccessFile.
|
static byte[] |
get4bitBytes(byte inByte)
Decomposes a byte (8-bits) into two 4-bit bytes.
|
static String |
getBitString(byte inByte)
Returns a string like "10110011" to represent the specified 8-bit byte.
|
static byte |
getByteFromBitString(String inByteString)
Returns the 8-bit byte corresponding to a specified string like "10110011".
|
static byte[] |
getBytesFromInt(int inValue)
Returns a byte[] corresponding to an int.
|
static char[] |
getCharArray(ByteSource inByteSource,
int inNumValues)
Returns a char[] derived from the specified ByteSource.
|
static char[] |
getCharArray(RandomAccessFile inRandomAccessFile,
int inNumValues)
Returns a char[] derived from the specified RandomAccessFile.
|
static float |
getFloat(InputStream inStream,
ByteOrder inByteOrder)
Returns a float from the given byte array.
|
static String |
getHexString(byte[] inBytes)
Returns a hex string representing the given byte array.
|
static int |
getInt(byte[] inBytes,
int inOffset,
ByteOrder inByteOrder)
Returns an int from the given byte array.
|
static int |
getInt(ByteSource inByteSource,
ByteOrder inByteOrder)
Returns an int from the current position of the specified ByteSource.
|
static int |
getInt(InputStream inStream,
ByteOrder inByteOrder)
Returns an int from the given byte array.
|
static int |
getInt(RandomAccessFile inRandomAccessFile)
Returns an int from the current position of the specified RandomAccessFile.
|
static int |
getInt(RandomAccessFile inRandomAccessFile,
ByteOrder inByteOrder)
Returns an int from the current position of the specified RandomAccessFile.
|
static long |
getLong(ByteSource inByteSource,
ByteOrder inByteOrder)
Returns an long from the current position of the specified ByteSource.
|
static long |
getLong(RandomAccessFile inRandomAccessFile,
ByteOrder inByteOrder)
Returns an long from the current position of the specified RandomAccessFile.
|
static short |
getShort(byte[] inBytes)
Returns a short from the first 2 bytes of the given byte array.
|
static short |
getShort(byte[] inBytes,
int inOffset)
Returns a short from the first 2 bytes of the given byte array.
|
static short |
getShort(byte[] inBytes,
int inOffset,
ByteOrder inByteOrder)
Returns a short from the first 2 bytes of the given byte array.
|
static short[] |
getShortArray(byte[] inBytes,
int inNumValues,
ByteOrder inByteOrder)
Returns a short[] derived from the specified byte[].
|
static short[] |
getShortArray(ByteSource inByteSource,
int inNumValues,
ByteOrder inByteOrder)
Returns a short[] derived from the specified ByteSource.
|
static short[] |
getShortArray(RandomAccessFile inRandomAccessFile,
int inNumValues,
ByteOrder inByteOrder)
Returns a short[] derived from the specified RandomAccessFile.
|
static String |
getString(byte[] inBytes,
int inOffset,
int inLength,
ByteOrder inByteOrder)
Returns a string from the bytes.
|
static String |
getString(ByteSource inByteSource,
int inLength)
Returns a String from the current position of the specified ByteSource.
|
static String |
getString(InputStream inStream,
int inLength)
Returns a string from the bytes.
|
static String |
getString(RandomAccessFile inRandomAccessFile,
int inLength)
Returns a String from the current position of the specified RandomAccessFile.
|
public ByteUtil()
public static String getBitString(byte inByte)
inByte
- the byte to be represented as a bit stringpublic static byte getByteFromBitString(String inByteString)
inByteString
- the bit string to be converted to a bytepublic static byte[] get4bitBytes(byte inByte)
inByte
- the source byte to be convertedpublic static String getHexString(byte[] inBytes)
inBytes
- the source byte arraypublic static int getInt(byte[] inBytes, int inOffset, ByteOrder inByteOrder)
inBytes
- the source byte arrayinOffset
- the offset within the source byte array from which to extract the intinByteOrder
- the byte order of the intpublic static int getInt(InputStream inStream, ByteOrder inByteOrder) throws IOException
inStream
- the InputStream source of bytesinByteOrder
- the byte order of the intIOException
public static int getInt(RandomAccessFile inRandomAccessFile) throws IOException
inRandomAccessFile
- the source of bytesIOException
public static int getInt(RandomAccessFile inRandomAccessFile, ByteOrder inByteOrder) throws IOException
inRandomAccessFile
- the source of bytesinByteOrder
- the byte order of the intIOException
public static int getInt(ByteSource inByteSource, ByteOrder inByteOrder) throws IOException
inByteSource
- the source of bytesinByteOrder
- the byte order of the intIOException
public static long getLong(RandomAccessFile inRandomAccessFile, ByteOrder inByteOrder) throws IOException
inRandomAccessFile
- the source of bytesinByteOrder
- the byte order of the longIOException
public static long getLong(ByteSource inByteSource, ByteOrder inByteOrder) throws IOException
inByteSource
- the source of bytesinByteOrder
- the byte order of the longIOException
public static int get2ByteInt(byte[] inBytes)
inBytes
- the source byte arraypublic static int get2ByteInt(byte[] inBytes, ByteOrder inByteOrder) throws IOException
inBytes
- the source byte arrayinByteOrder
- the byte order of the intIOException
public static int get2ByteInt(byte[] inBytes, int inOffset, ByteOrder inByteOrder) throws IOException
inBytes
- the source byte arrayinOffset
- the offset within the source byte array from which to extract the intinByteOrder
- the byte order of the intIOException
public static int get2ByteInt(InputStream inStream) throws IOException
inStream
- the InputStream source of bytesIOException
public static int get2ByteInt(InputStream inStream, ByteOrder inByteOrder) throws IOException
inStream
- the InputStream source of bytesinByteOrder
- the byte order of the intIOException
public static int get2ByteInt(RandomAccessFile inRandomAccessFile, ByteOrder inByteOrder) throws IOException
inRandomAccessFile
- the source of bytesinByteOrder
- the byte order of the intIOException
public static int get2ByteInt(ByteSource inByteSource, ByteOrder inByteOrder) throws IOException
inByteSource
- the source of bytesinByteOrder
- the byte order of the intIOException
public static int get2ByteInt(byte[] inBytes, int inOffset)
inBytes
- the source byte arrayinOffset
- the offset within the source byte array from which to extract the intpublic static int get1ByteInt(byte[] inBytes, int inOffset)
inBytes
- the source byte arrayinOffset
- the offset within the source byte array from which to extract the intpublic static short getShort(byte[] inBytes)
inBytes
- the source byte arraypublic static short getShort(byte[] inBytes, int inOffset)
inBytes
- the source byte arrayinOffset
- the offset within the source byte array from which to extract the intpublic static short getShort(byte[] inBytes, int inOffset, ByteOrder inByteOrder)
inBytes
- the source byte arrayinOffset
- the offset within the source byte array from which to extract the intinByteOrder
- the byte order of the shortpublic static float getFloat(InputStream inStream, ByteOrder inByteOrder) throws IOException
inStream
- the InputStream source of bytesinByteOrder
- the byte order of the floatIOException
public static String getString(byte[] inBytes, int inOffset, int inLength, ByteOrder inByteOrder)
inBytes
- the source byte arrayinOffset
- the offset within the source byte array from which to extract the StringinLength
- the number of bytes to include in the StringinByteOrder
- the byte order of the stringpublic static String getString(InputStream inStream, int inLength) throws IOException
inStream
- the InputStream source of bytesinLength
- the number of bytes to include in the StringIOException
public static String getString(RandomAccessFile inRandomAccessFile, int inLength) throws IOException
inRandomAccessFile
- the source of bytesinLength
- the number of bytes to include in the StringIOException
public static String getString(ByteSource inByteSource, int inLength) throws IOException
inByteSource
- the source of bytesinLength
- the number of bytes to include in the StringIOException
public static byte[] getBytesFromInt(int inValue) throws IOException
inValue
- the int to decompose into an array of 4 bytesIOException
public static short[] getShortArray(byte[] inBytes, int inNumValues, ByteOrder inByteOrder)
inBytes
- the source byte arrayinNumValues
- the number of shorts to extract from the source byte arrayinByteOrder
- the byte order of the stringpublic static short[] getShortArray(RandomAccessFile inRandomAccessFile, int inNumValues, ByteOrder inByteOrder) throws IOException
inRandomAccessFile
- the source of bytes; assumes that the file is already set to the proper positioninNumValues
- the number of shorts to extract from the source byte arrayinByteOrder
- the byte order of the stringIOException
public static short[] getShortArray(ByteSource inByteSource, int inNumValues, ByteOrder inByteOrder) throws IOException
inByteSource
- the source of bytes; assumes that the file is already set to the proper positioninNumValues
- the number of shorts to extract from the source byte arrayinByteOrder
- the byte order of the stringIOException
public static char[] getCharArray(RandomAccessFile inRandomAccessFile, int inNumValues) throws IOException
inRandomAccessFile
- the source of bytes; assumes that the file is already set to the proper positioninNumValues
- the number of shorts to extract from the source byte arrayIOException
public static char[] getCharArray(ByteSource inByteSource, int inNumValues) throws IOException
inByteSource
- the source of bytes; assumes that the file is already set to the proper positioninNumValues
- the number of shorts to extract from the source byte arrayIOException