String a = "a";
String b = "b";
String c = "c";
byte[] bytes = a.getBytes(); b.getBytes(); c.getBytes();
StringBuilder binary = new StringBuilder();
for (byte byt : bytes) {
int val = byt;
for (int i = 0; i < 8; i++) {
binary.append((val & 128) == 0 ? 0 : 1);
val <<= 1;
}
binary.append(' ');
}
Displaytext.setText(UserInput.getText() + " = " + binary);
答案 0 :(得分:0)
您只需要使用用户输入来初始化输入数组:
byte[] bytes = UserInput.getText().getBytes();