List of utility methods to do Byte Array to Short
short | arr2short(byte[] arr) arrshort int i = 0; i |= arr[0] & 0xFF; i <<= 8; i |= arr[1] & 0xFF; return (short) i; |
short | bufferToShort(byte[] ioBuffer) buffer To Short return (short) ((ioBuffer[0] << 8) | (ioBuffer[1] & 255)); |
short[] | byte2short(byte[] ba) byteshort int length = ba.length; short[] sa = new short[length / 2]; for (int i = 0, j = 0; j < length / 2;) { sa[j++] = (short) (((ba[i++] & 0xFF) << 8) | ((ba[i++] & 0xFF))); return (sa); |
short | byte2short(byte[] data) byteshort if (data != null && data.length == 2) { return (short) (((data[1] & 0xff) << 8) + (data[0] & 0xff)); return 0; |
short | byte2short(byte[] value, int offset) byteshort long result = (((long) (value[0 + offset]) & 0xFF) << 8) | ((long) (value[1 + offset]) & 0xFF); return (short) (result & 0xFFFFL); |
short | byte2Short(int loc, byte b[]) byte Short short m1, m2; m1 = (short) (b[loc]); if (m1 < 0) m1 = (short) (256 + m1); m2 = (short) (b[loc + 1]); if (m2 < 0) m2 = (short) (256 + m2); m2 = (short) (256 * m2 + m1); ... |
short | bytes2short(byte[] b) to short. return bytes2short(b, 0); |
short | bytes2Short(byte[] bytes) bytes Short short val = 0; for (int i = 0; i < 2; i++) { val |= (0xFF & (short) bytes[i]) << (8 * i); return val; |
short | bytes2short(byte[] bytes, int offset, boolean bigEndian) bytesshort short val = 0; if (bigEndian) { val += (bytes[offset + 0] & 0xff) << 8; val += (bytes[offset + 1] & 0xff); } else { val += (bytes[offset + 1] & 0xff) << 8; val += (bytes[offset + 0] & 0xff); return val; |
short | bytes2Short(byte[] input) bytes Short return (short) ((input[0] & 0xFF) | ((input[1] << 8) & 0xFF00)); |