public class BinConverter
extends java.lang.Object
| Constructor and Description |
|---|
BinConverter() |
| Modifier and Type | Method and Description |
|---|---|
static int |
byteArrayToInt(byte[] buf,
int nOfs)
Gets bytes from an array into an integer.
|
static long |
byteArrayToLong(byte[] buf,
int nOfs)
Gets bytes from an array into a long.
|
static java.lang.String |
byteArrayToStr(byte[] data,
int nOfs,
int nLen)
Converts a byte array into a Unicode string.
|
static java.lang.String |
bytesToHexStr(byte[] data)
Converts a byte array to a hex string.
|
static java.lang.String |
bytesToHexStr(byte[] data,
int nOfs,
int nLen)
Converts a byte array to a hex string.
|
static int |
hexStrToBytes(java.lang.String sHex,
byte[] data,
int nSrcOfs,
int nDstOfs,
int nLen)
Converts a hex string back into a byte array (invalid codes will be
skipped).
|
static long |
intArrayToLong(int[] buf,
int nOfs)
Converts values from an integer array to a long.
|
static void |
intToByteArray(int nValue,
byte[] buf,
int nOfs)
Converts an integer to bytes, which are put into an array.
|
static int |
longHi32(long lVal)
Gets the higher 32 bits of a long.
|
static int |
longLo32(long lVal)
Gets the lower 32 bits of a long.
|
static void |
longToByteArray(long lValue,
byte[] buf,
int nOfs)
Converts a long to bytes, which are put into an array.
|
static void |
longToIntArray(long lValue,
int[] buf,
int nOfs)
Converts a long to integers which are put into an array.
|
static long |
makeLong(int nLo,
int nHi)
Makes a long from two integers (treated unsigned).
|
public static final int byteArrayToInt(byte[] buf,
int nOfs)
buf - where to get the bytesnOfs - index from where to read the datapublic static final void intToByteArray(int nValue,
byte[] buf,
int nOfs)
nValue - the 32bit integer to convertbuf - the target bufnOfs - where to place the bytes in the bufpublic static final long byteArrayToLong(byte[] buf,
int nOfs)
buf - where to get the bytesnOfs - index from where to read the datapublic static final void longToByteArray(long lValue,
byte[] buf,
int nOfs)
lValue - the 64bit integer to convertbuf - the target bufnOfs - where to place the bytes in the bufpublic static final long intArrayToLong(int[] buf,
int nOfs)
buf - where to get the bytesnOfs - index from where to read the datapublic static final void longToIntArray(long lValue,
int[] buf,
int nOfs)
lValue - the 64bit integer to convertbuf - the target bufnOfs - where to place the bytes in the bufpublic static final long makeLong(int nLo,
int nHi)
nLo - lower 32bitsnHi - higher 32bitspublic static final int longLo32(long lVal)
lVal - the long integerpublic static final int longHi32(long lVal)
lVal - the long integerpublic static final java.lang.String bytesToHexStr(byte[] data)
data - the byte arraypublic static final java.lang.String bytesToHexStr(byte[] data,
int nOfs,
int nLen)
data - the byte arraynOfs - start index where to get the bytesnLen - number of bytes to convertpublic static final int hexStrToBytes(java.lang.String sHex,
byte[] data,
int nSrcOfs,
int nDstOfs,
int nLen)
sHex - hex stringdata - the target arraynSrcOfs - from which character in the string the conversion should
begin, remember that (nSrcPos modulo 2) should equals 0 normallynDstOfs - to store the bytes from which position in the arraynLen - number of bytes to extractpublic static final java.lang.String byteArrayToStr(byte[] data,
int nOfs,
int nLen)
data - the byte arraynOfs - where to begin the conversionnLen - number of bytes to handle