I have a GUI where i try to convert a EBCDIC String into Hexadecimal, but it will not work :/
ebcdichex.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
output6.setText("");
String hexadecimal3 = input4.getText().replace("\n", "");
byte[] chars2;
try {
chars2 = hexadecimal3.getBytes("IBM-273");
StringBuilder hexa2 = new StringBuilder();
for(int i = 0;i<chars2.length;i++){
byte[] b = {(byte) Integer.parseInt(chars2.toString(),16)};
hexa2.append(b);
}
output6.append(hexa2.toString());
}
catch (UnsupportedEncodingException e1) {
e1.printStackTrace();
}
}
});
Example input:
f1f2f3f4
translated:
1234
It just throws this Error:
Exception in thread "AWT-EventQueue-0" java.lang.NumberFormatException: For input string: "[B@147c5fc"
What is wrong with this code?