Convert binary to hexadecimal

Asked

Viewed 1,372 times

2

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

1 answer

2


You can do it like this

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

And hexadecimal to binary as well

String bin = Integer.toString(Integer.parseInt("ff", 16), 2);

Browser other questions tagged

You are not signed in. Login or sign up in order to post.