List of utility methods to do Byte Array to Int Convert
int | bytes2uint(byte[] bytes, int from, int to) bytesuint int result = 0; int len = to - from; for (int i = from; i < to; i++) { int shiftValue = (to - i - 1) * 8; result += (bytes[i] << shiftValue) & (0x0000FFFF >>> ((len - 1) * 8 - shiftValue)); return result; ... |
int | bytesBE2int(byte[] b, int off) bytes B Eint return ((b[off] & 0xff) << 24) | ((b[off + 1] & 0xff) << 16)
| ((b[off + 2] & 0xff) << 8) | (b[off + 3] & 0xff);
|
int[] | bytesBE2ints(byte[] b) bytes B Eints if (b == null) return null; if ((b.length & 0x3) != 0) throw new IllegalArgumentException("byte[" + b.length + "]"); int[] val = new int[b.length >> 2]; for (int i = 0; i < val.length; i++) val[i] = bytesBE2int(b, i << 2); return val; ... |
int | getInt(byte b) get Int return (0xff & b);
|
int | getInt(byte[] bb, int index) get Int return (int) ((((bb[index + 0] & 0xff) << 24) | ((bb[index + 1] & 0xff) << 16) | ((bb[index + 2] & 0xff) << 8) | ((bb[index + 3] & 0xff) << 0))); |
int | getInt(byte[] bb, int index) get Int return (int) ((((bb[index + 0] & 0xff) << 24) | ((bb[index + 1] & 0xff) << 16) | ((bb[index + 2] & 0xff) << 8) | ((bb[index + 3] & 0xff) << 0))); |
int | getInt(byte[] bb, int index) get Int return (int) ((((bb[index + 3] & 0xff) << 24) | ((bb[index + 2] & 0xff) << 16) | ((bb[index + 1] & 0xff) << 8) | ((bb[index + 0] & 0xff) << 0))); |
int | getInt(byte[] buf, boolean bigEndian) Convert byte sequence into java short from first 4 bytes return getInt(buf, 0, bigEndian);
|
int | getInt(byte[] buf, int pos, boolean bigEndian) Convert byte sequence into java int. if (bigEndian) { return ((buf[pos] & 0xff) << 24) | ((buf[pos + 1] & 0xff) << 16) | ((buf[pos + 2] & 0xff) << 8) | (buf[pos + 3] & 0xff); } else { return ((buf[pos + 3] & 0xff) << 24) | ((buf[pos + 2] & 0xff) << 16) | ((buf[pos + 1] & 0xff) << 8) | (buf[pos] & 0xff); ... |
int | getInt(byte[] buffer, int pos, int count) Get integer? int ret = 0; for (int i = 0; i < 4 && i < count && (i + pos) < buffer.length; i++) { ret *= 256; ret += toUnsignedInteger(buffer[i + pos]); return ret; |