Integer.toBinaryString(data)
gives me a binary String representation of my array data.
However I would like a simple way to add leading ze
You could override that function in your own class:
public static String toBinaryString(int x){ byte[] b = new byte[32]; // 32 bits per int int pos = 0; do{ x = x >> 1; // /2 b[31-pos++] = (byte)(x % 2); }while(x > 0); return Arrays.toString(b); }