List of utility methods to do Mac Address Get
String | getMACAddress() Tries to determine the MAC address of the machine Kettle is running on. String ip = getIPAddress(); String mac = "none"; String os = getOS(); String s = ""; if (os.equalsIgnoreCase("Windows NT") || os.equalsIgnoreCase("Windows 2000") || os.equalsIgnoreCase("Windows XP") || os.equalsIgnoreCase("Windows 95") || os.equalsIgnoreCase("Windows 98") || os.equalsIgnoreCase("Windows Me") || os.startsWith("Windows")) { ... |
String | getMacAddress() get Mac Address Enumeration<NetworkInterface> networkInterfaces = NetworkInterface.getNetworkInterfaces(); int count = 0; while (networkInterfaces.hasMoreElements()) { NetworkInterface networkInterface = networkInterfaces.nextElement(); count++; byte[] bmac = networkInterface.getHardwareAddress(); if (bmac != null) { String mac = macBytesToString(bmac); ... |
String | getMacAddress() Returns the computer MAC address in 5C-26-0A-88-4E-DA format. String macAddress = null; try { InetAddress ip = InetAddress.getLocalHost(); NetworkInterface network = NetworkInterface.getByInetAddress(ip); if (network == null) { macAddress = "00"; return macAddress; byte[] mac = network.getHardwareAddress(); if (mac == null) { macAddress = "00"; return macAddress; StringBuilder sb = new StringBuilder(); for (int i = 0; i < mac.length; i++) { sb.append(String.format("%02X%s", mac[i], (i < mac.length - 1) ? "-" : "")); macAddress = sb.toString(); return macAddress; } catch (Exception e) { macAddress = "00"; return macAddress; |
String | getMacAddress() get Mac Address String mac = ""; String os = System.getProperty("os.name"); try { if (os.startsWith("Windows")) { mac = windowsParseMacAddress(windowsRunIpConfigCommand()); } else if (os.startsWith("Linux")) { mac = linuxParseMacAddress(linuxRunIfConfigCommand()); } else if (os.startsWith("Mac OS X")) { ... |
Long | getMacAddress() Reads the MAC address of the machine. try { final InetAddress addr = getLocalHost(); final NetworkInterface ni = NetworkInterface.getByInetAddress(addr); final byte[] mac = ni.getHardwareAddress(); return ((long) mac[5] & 0xff) + (((long) mac[4] & 0xff) << 8) + (((long) mac[3] & 0xff) << 16) + (((long) mac[2] & 0xff) << 24) + (((long) mac[1] & 0xff) << 32) + (((long) mac[0] & 0xff) << 40); } catch (Throwable e) { ... |
String | getMacAddress() get Mac Address NetworkInterface network = NetworkInterface.getByInetAddress(getLocalAddress()); byte[] mac = network.getHardwareAddress(); StringBuilder sb = new StringBuilder(); for (int i = 0; i < mac.length; i++) { sb.append(String.format("%02X%s", mac[i], (i < mac.length - 1) ? "-" : "")); return sb.toString(); |
String | getMacAddress(String host) get Mac Address String mac = ""; StringBuffer sb = new StringBuffer(); try { NetworkInterface ni = NetworkInterface.getByInetAddress(InetAddress.getByName(host)); } catch (SocketException e) { e.printStackTrace(); } catch (UnknownHostException e) { e.printStackTrace(); ... |
String | getMACAddress(String interfaceName) Returns MAC address of the given interface name. try { List<NetworkInterface> interfaces = Collections.list(NetworkInterface.getNetworkInterfaces()); for (NetworkInterface intf : interfaces) { if (interfaceName != null) { if (!intf.getName().equalsIgnoreCase(interfaceName)) continue; byte[] mac = intf.getHardwareAddress(); ... |
String | getMacAddress(String separator) get Mac Address 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); ... |
byte[] | getMacAddressBytes() get Mac Address Bytes final NetworkInterface ni = NetworkInterface.getByInetAddress(InetAddress.getLocalHost()); return ni.getHardwareAddress(); |