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 bytes convert method In Kotlin works for me:
fun toBytes(s: Short): ByteArray { return byteArrayOf((s.toInt() and 0x00FF).toByte(), ((s.toInt() and 0xFF00) shr (8)).toByte()) }