Convert binary to hexadecimal

2

Is there any function equivalent to bin2hex () of php for Java? I need to convert a binary to hexadecimal.

    
asked by anonymous 08.12.2015 / 13:41

1 answer

2

You can do so

String hexa = Integer.toString(Integer.parseInt("1111", 2), 16);

And from hexadecimal to binary too

String bin = Integer.toString(Integer.parseInt("ff", 16), 2);
    
08.12.2015 / 13:47