Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我有一个在 Java 中表示为 byte[] 的 MAC 地址,并希望它作为十六进制字符串,因为它们通常表示。我怎样才能尽可能简单地做到这一点?
字节数组的长度为 6。
尝试这个:
String hexValue = String.format("%02X:%02X:%02X:%02X:%02X:%02X", mac[0], mac[1], mac[2], mac[3], mac[4], mac[5]);