I want to convert a string into a binary string.
I have tried
String str = "123";
int foo1 = Integer.valueOf(str);
String strbinary = Integer.toBinaryString(foo1);
It is giving the correct result but it is not useful because the output I am getting is 1111011, but the desired output is 01111011.
Is there some other better way to convert string into binary? I want it 0-padding, in my case for 0-padding I want it just an even binary string, doesn't want everytime 16 digit binary as in this case
String.format("%16s", Integer.toBinaryString(1)).replace(' ', '0')