This is because Integer.toBinaryString() cuts leading zeros.

For instance, '5' becomes 110101 (6 bits) and 'a' becomes 1100001 (7 bits). In both cases, the leading zeros were omitted.

Since omitting leading zeros makes it impossible to decode a continuous message of bytes, you will have to pad in the omitted zeros before encoding the message.

Ultime modifiche: Wednesday, 11 March 2015, 11:42