I have a variable of type ByteArray:
val byteArray: ByteArray?
I am currently accessing its first byte, indexing it as follows: byteArray[0]. I want to be able to get the first two bytes on this byte array. Should I get byte 0 and 1 and then append, or can I do byteArray[0:1] somehow? I am very new to Java and Kotlin and any guidance is appreciated.
I need to be able to get the first two bytes , so then I can get bits 0 to 16 and convert it to an integer. I use this to convert bytes to binary string:
`String.format("%8s", Integer.toBinaryString(inByte & 0xFF)).replace(' ', '0');`