List of utility methods to do Byte Array to Short Convert
short | getShort(byte[] b, int index) get Short return (short) (((b[index + 1] << 8) | b[index + 0] & 0xff)); |
short | getShort(byte[] buf, boolean bigEndian) Convert byte sequence into java short from first 2 bytes return getShort(buf, 0, bigEndian);
|
short | getShort(byte[] buf, int pos, boolean bigEndian) Convert byte sequence into java short. if (bigEndian) { return (short) ((buf[pos] << 8) | (buf[pos + 1] & 0xff)); } else { return (short) ((buf[pos + 1] << 8) | (buf[pos] & 0xff)); |
short | getShort(byte[] bytes) get Short return (short) ((0xff & bytes[0]) | (0xff00 & (bytes[1] << 8))); |
short | toShort(byte[] b, int pos) to Short short ret = 0; ret |= (b[pos] & 0xFF); ret |= (b[pos + 1] & 0xFF) << 8; return ret; |
short | toShort(byte[] data) to Short return byteArrayToShort(data, 0);
|
short | toShort(byte[] data) to Short if (data == null || data.length != 2) return 0x0; return (short) ((0xff & data[0]) << 8 | (0xff & data[1]) << 0); |
short | makeShort(byte b1, byte b0) make Short return (short) ((b1 << 8) | (b0 & 0xff)); |
short | bytes2short(byte[] data) bytesshort short val = 0; val |= data[0] & 0x00FF; val |= data[1] << 8; return val; |
String | ByteToString(byte[] byteArray) Byte To String if (byteArray == null) { return null; try { String result = new String(byteArray, "ASCII"); result = String.copyValueOf(result.toCharArray(), 0, byteArray.length); return result; ... |