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
An alternative that is more efficient:
// Little Endian ret[0] = (byte) x; ret[1] = (byte) (x >> 8); // Big Endian ret[0] = (byte) (x >> 8); ret[1] = (byte) x;