List of utility methods to do Mac Address to String
byte[] | macToBinary(String mac) mac To Binary byte[] macBytes = new byte[6]; try { String[] strArr = mac.split(":"); for (int i = 0; i < strArr.length; i++) { int value = Integer.parseInt(strArr[i], 16); macBytes[i] = (byte) value; } catch (Exception e) { ... |
String | macToStr(byte[] mac) Converts a MAC address to colon hexadecimal representation (e.g., "00:01:02:03:04:05"). StringBuilder strBuilder = new StringBuilder(); for (int i = 0; i < mac.length; i++) { strBuilder.append(String.format("%02X", mac[i])); if (i < mac.length - 1) { strBuilder.append(":"); return strBuilder.toString(); ... |
String | macToString(byte[] mac) mac To String StringBuilder b = new StringBuilder(); for (int i = 0; i < mac.length; i++) { b.append(String.format("%02X%s", mac[i], (i < mac.length - 1) ? ":" : "")); return b.toString(); |
String | macToString(byte[] mac) mac To String StringBuilder sb = new StringBuilder(); for (int i = 0; i < 6; i++) { String octet = (Integer.toHexString(mac[i] & 0xFF)).toUpperCase(); if (octet.length() == 1) { sb.append("0"); sb.append(octet); if (i != 5) { ... |
String | macToString(final byte[] address) Convert specified array of bytes into an mac address string. final StringBuffer sb = new StringBuffer(address.length * 3); for (int i = 0; i < address.length; i++) { if (0 != i) { sb.append(':'); appendHexValue(sb, address[i]); return sb.toString(); ... |
String | macToString(long macAddress) mac To String String value = String.format("%012x", macAddress); char[] chars = value.toCharArray(); final StringBuilder stringBuilder = new StringBuilder(); stringBuilder.append(chars[0]).append(chars[1]); for (int pos = 2; pos < value.length(); pos += 2) { stringBuilder.append(":").append(chars[pos]).append(chars[pos + 1]); return stringBuilder.toString(); ... |
String | macToString(String srcstr) mac To String if (srcstr == null) { return "null"; StringBuffer buf = new StringBuffer(); for (int i = 0; i < srcstr.length(); i = i + 3) { buf.append(srcstr.charAt(i)); buf.append(srcstr.charAt(i + 1)); return buf.toString(); |