Java Utililty Methods Bit Unpack

List of utility methods to do Bit Unpack

Description

The list of methods to do Bit Unpack are organized into topic(s).

Method

byteunpackByte(String bits)
Unpack a binary string ("10011...") into a byte
return Byte.parseByte(bits, 2);
byte[]unpackBytes(String src)
Unpacks data from string representation.
byte[] data = src.getBytes();
int srcLen, len;
byte[] res = new byte[len = ((srcLen = data.length) >> 3) * 7 + (srcLen & 7) - 1];
int i = 0;
for (int k = len; k < srcLen; k++) {
    int mask = data[k];
    for (int j = 0; j < 7 && i < len; j++, i++) {
        res[i] = ((mask & (1 << j)) == 0) ? data[i] : (byte) (data[i] | 0x80);
...
intunpackUnsignedByte(byte b)
Since byte is a signed type you cannot receive the unsigned value even if you do (byte) 200 .
return b >= 0 ? b : b + 256;