这是我想要做的。我有一个字符串:
String s="ch"
我通过以下方式将其转换为二进制字符串
char ar[]=s.toCharArray();
StringBuilder sb= new StringBuilder("00"); /* i am appending to extra zeros because
when i convert "ch" to binary string it
consists of 14 characters(0s and 1s) and i
need them to be a multiple of 8, so i add 2
0s to make it 16)*/
String wm=" ";
for(char c:ar)
{
wm=Integer.toBinaryString((int)c);
sb.append(wm);
}
现在我想将这个二进制字符串转换回字符......这样我就可以得到“ch”作为输出。任何人都可以帮忙吗?