user567 user567 - 1 year ago 224
Java Question

Convert from big Endian to Hex String with java

How can I convert from 16-bit unsigned integer big Endian to Hex String? I want to make the inverse of what you can see in the screenshot.
enter image description here

From the Big Endian value

I want to have as a result
. I tried this but I got as result
71 48 97 92
which is a totally different value that expected


Answer Source

You can use this:

String hex = Integer.toHexString(13089);
System.out.println(hex) //prints 3321

You don't have to reverse bytes because its already a big-endian representation.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download