List of utility methods to do Byte Array to Int Convert
void | getInts(int[] toInts, byte[] fromBytes) get Ints for (int intInd = 0; intInd < toInts.length; ++intInd) { final int fromInt = getInt(intInd * 4, fromBytes); int toInt = fromInt; toInts[intInd] = toInt; |
void | getInts(int[] toInts, byte[] fromBytes, int fromOffset) get Ints for (int intInd = 0; intInd < toInts.length; ++intInd) { final int fromInt = getInt(fromOffset + (intInd * INT_SIZE), fromBytes); int toInt = fromInt; toInts[intInd] = toInt; |
int | getUIntByByte(byte data) new byte[] { 8, 4, 2, 1 } => 00000001 00000010 00000100 00001000 return data & 0xFF;
|
long | getUIntByByteArray(byte[] data) new byte[] { 8, 4, 2, 1 } => 00000001 00000010 00000100 00001000 return getUIntByByteArray(data, true);
|
long | getUIntByByteArray(byte[] data, boolean isLH) get U Int By Byte Array long result = 0; for (int i = 0; i < data.length; i++) { byte b = data[i]; int t = getUIntByByte(b); result += t << ((isLH ? i : data.length - i - 1) * 8); return result; |
int | toInt(byte[] src) to Int return toInt(src, 0);
|
int | toInt(byte[] src, int srcPos) to Int int dword = 0; for (int i = 0; i < 4; i++) { dword = (dword << 8) + (src[i + srcPos] & 0xFF); return dword; |
int | toIntFromTwoBytes(byte[] b, int pos) to Int From Two Bytes int ret = 0; ret |= (b[pos] & 0xFF); ret |= (b[pos + 1] & 0xFF) << 8; return (int) ret; |
int | toInteger(byte[] b, int pos) to Integer int ret = 0; for (int i = 0; i < 4; i++) { ret |= (b[i + pos] & 0xFF) << (8 * i); return ret; |
int | toInteger(byte[] b, int pos, int width) to Integer int retVal = Integer.MAX_VALUE; switch (width) { case 1: retVal = b[pos]; if (retVal < 0) { retVal &= 0x000000FF; break; ... |