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.

0

1 Answer 1

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]);
Sign up to request clarification or add additional context in comments.

1 Comment

This works and the formating is perfect.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.