Here you can find the source of getAddrInfo(InetAddress pAddr)
private static String getAddrInfo(InetAddress pAddr) throws SocketException
//package com.java2s; //License from project: Apache License import java.lang.reflect.Method; import java.net.*; public class Main { private static Method isUp; private static Method supportsMulticast; private static String getAddrInfo(InetAddress pAddr) throws SocketException { String ret = pAddr.getHostName() != null ? pAddr.getHostName() + " (" + pAddr.getHostAddress() + ")" : pAddr.getHostAddress(); ret += " [site-local: " + pAddr.isSiteLocalAddress() + ", link-local: " + pAddr.isLinkLocalAddress() + ", lb: " + pAddr.isLoopbackAddress() + "]"; NetworkInterface nif = NetworkInterface.getByInetAddress(pAddr); ret += " -- nif: " + getNetworkInterfaceInfo(nif); return ret; }/*from ww w .j av a2 s .c o m*/ private static String getNetworkInterfaceInfo(NetworkInterface pNif) throws SocketException { if (pNif == null) { return "[null]"; } return pNif.getDisplayName() + " [up: " + pNif.isUp() + ", mc: " + pNif.supportsMulticast() + ", lb: " + pNif.isLoopback() + ", hw: " + formatHwAddress(pNif.getHardwareAddress()) + "]"; } private static String formatHwAddress(byte[] pHardwareAddress) { if (pHardwareAddress == null) { return "[none]"; } StringBuilder sb = new StringBuilder(18); for (byte b : pHardwareAddress) { if (sb.length() > 0) { sb.append(':'); } sb.append(String.format("%02x", b)); } return sb.toString(); } }