【发布时间】:2012-05-04 05:02:39
【问题描述】:
我编写了这段代码用于将二进制转换为文本。
public static void main(String args[]) throws IOException{
BufferedReader b = new BufferedReader(new InputStreamReader(System.in));
System.out.println("Enter a binary value:");
String h = b.readLine();
int k = Integer.parseInt(h,2);
String out = new Character((char)k).toString();
System.out.println("string: " + out);
}
}
看看输出!
Enter a binary value:
0011000100110000
string: ?
有什么问题?
【问题讨论】:
-
你希望输出是什么?
-
输出应该是字符串,例如 0011010100110101 = 55 或 011000010110000101100001 = aaa
-
您希望它被解析为 ASCII....?还是什么?
-
我希望它转换为文本(ascii)