Here you can find the source of getMacAddress(String separator)
public static String getMacAddress(String separator) throws SocketException, UnknownHostException
//package com.java2s; //License from project: Open Source License import java.net.InetAddress; import java.net.NetworkInterface; import java.net.SocketException; import java.net.UnknownHostException; public class Main { public static String getMacAddress() throws SocketException, UnknownHostException { return getMacAddress(':'); }/* w w w.j a v a 2 s. c o m*/ public static String getMacAddress(char separator) throws SocketException, UnknownHostException { return getMacAddress(String.valueOf(separator)); } public static String getMacAddress(String separator) throws SocketException, UnknownHostException { final StringBuilder macAddress = new StringBuilder(); final InetAddress localHost = InetAddress.getLocalHost(); final NetworkInterface networkInterface = NetworkInterface.getByInetAddress(localHost); if (networkInterface == null) { return null; } for (byte b : networkInterface.getHardwareAddress()) { macAddress.append(String.format("%02X", b)).append(separator); } return macAddress.substring(0, macAddress.length() - separator.length()); } }