/** * @return a list with all IP addresses */ public static List<InetAddress> getAllIpAddresses() { return getIpAddressesList(false); }
/** * Get the local host name (e.g. someone.corp.axway.com) * * @return */ public static String getLocalHostName() { String localHostName = ""; InetAddress inetAddress = null; List<InetAddress> ipList = getIpAddressesList(true); if (ipList.size() > 0) { inetAddress = ipList.get(0); } if (inetAddress != null) { localHostName = inetAddress.getHostName(); } return localHostName; }
/** * Get the IP (not the loopback 127.0.0.1) of the local host. Note: it will * return the first valid one, so the result is not clear when have more * than one network card installed. * * @return */ public static String getLocalHostIP() { String localHostIP = ""; InetAddress inetAddress = null; List<InetAddress> ipList = getIpAddressesList(true); if (ipList.size() > 0) { inetAddress = ipList.get(0); } if (inetAddress != null) { localHostIP = inetAddress.getHostAddress(); } return localHostIP; }
} else { if (tmpPublicAddress.isLoopbackAddress()) { List<InetAddress> ipList = getIpAddressesList(true); if (ipList.size() > 0) { tmpPublicAddress = ipList.get(0); List<InetAddress> ipList = getIpAddressesList(true); if (ipList.size() > 0) { localHostPublicAddress = ipList.get(0);