How can I convert a short (2 bytes) to a byte array in Java, e.g.
short
short x = 233; byte[] ret = new byte[2]; ...
it should be s
short to byte
short x=17000; byte res[]=new byte[2]; res[i]= (byte)(((short)(x>>7)) & ((short)0x7f) | 0x80 ); res[i+1]= (byte)((x & ((short)0x7f)));
byte to short
short x=(short)(128*((byte)(res[i] &(byte)0x7f))+res[i+1]);