Java tutorial
//package com.java2s; import java.util.Locale; public class Main { private static void test_getMacAddressStr() { String bssid = "18:03:56:78:90:ab"; byte[] bssidBytes = new byte[] { 0x18, 0x03, 0x56, 0x78, (byte) 0x90, (byte) 0xab }; String bssid1 = getMacAddressStr(bssidBytes); if (bssid.equals(bssid1)) { System.out.println("test_getMacAddressStr() pass"); } else { System.out.println("test_getMacAddressStr() fail"); } } /** * Get the mac address String format by the device's bssid bytes format * @param bssidBytes the device's bssid bytes format * @return the mac address String format */ public static String getMacAddressStr(byte[] bssidBytes) { StringBuilder sb = new StringBuilder(); String segmentStr = null; for (int i = 0; i < bssidBytes.length; ++i) { segmentStr = Integer.toHexString(0xff & bssidBytes[i]); if (segmentStr.length() == 1) { sb.append("0"); } sb.append(segmentStr); if (i != bssidBytes.length - 1) { sb.append(':'); } } return sb.toString().toLowerCase(Locale.US); } }