when converting int to binary, how to output it to 8 character, currently it only display 1 and short of the 7 zeros
int x = 1;
String bin = Int
You can pad your binary string with zeroes.
String bin = String.format("%8s", Integer.toBinaryString(x).replace(' ', '0');
I am not sure if that is what you mean but how about something like
String.format("%8s", Integer.toBinaryString(1)).replace(' ', '0')
will generate 00000001
Convert, check the resulting length and add zeros if < 8.