1

I have a MAC address represented as a byte[] in Java and want it as a hexadecimal string, as they are usually represented. How can I do this with as easy as possible?

The byte array has length 6.

1 Answers1

3

Try this:

String hexValue = String.format("%02X:%02X:%02X:%02X:%02X:%02X", mac[0], mac[1], mac[2], mac[3], mac[4], mac[5]);
morgano
  • 17,210
  • 10
  • 45
  • 56