Convert short to byte[] in Java

ret[0] = (byte)(x & 0xff);
ret[1] = (byte)((x >> 8) & 0xff);

Leave a Comment