Hi everybody
An easy question. I have a byte[] variable and I want to build a String with the binary representation of this variable. I have created the following code:
byte[] data;
String binary = "";
....
for (int i=0; i<data.length;i++)
{
valueLong = data[i] & 0xFF;
binary = binary + Long.toBinaryString(valueLong);
}
The problem with this method is that for example if the byte value is 0, the String value of this byte will be "0" and not "00000000". Anybody knows how to convert a byte to an 8-bit binary String?