binary string with leading zeros issue
问题 I have a string which is converted in binary format but the binary conversion method removes it leading zero's and I am not sure how much leading zero's I should add in the start .It depends on the string my code is as follows public static void encodeString(String str){ byte[] bytes=str.getBytes(); String binary = new BigInteger(bytes).toString(2); } 回答1: I understand that you are trying to preserve the 8-bits representation of each character of your input String . to do so, I used this