List of utility methods to do IP Address Get
String | getLocalIP() get Local IP String sIP = ""; InetAddress ip = null; try { boolean bFindIP = false; Enumeration<NetworkInterface> netInterfaces = (Enumeration<NetworkInterface>) NetworkInterface .getNetworkInterfaces(); while (netInterfaces.hasMoreElements()) { if (bFindIP) { ... |
InetAddress | getLocalIP() Retrieves the IP address of the local computer: - If there exists an interface different from "loopback" it will never return "127.0.0.1" - If there exists multiple network interfaces, the first one will be returned try { Collection<InterfaceAddress> ips = getAllIPAddresses(); if (ips.size() > 0) { return (InetAddress) ips.iterator().next().getAddress(); } else { return null; } catch (Exception e) { ... |
String | getLocalIp() get Local Ip try { Enumeration<NetworkInterface> interfaces = NetworkInterface.getNetworkInterfaces(); while (interfaces.hasMoreElements()) { NetworkInterface current = interfaces.nextElement(); if (!current.isUp() || current.isLoopback() || current.isVirtual()) { continue; Enumeration<InetAddress> addresses = current.getInetAddresses(); ... |
String | getLocalIP() get Local IP StringBuilder IFCONFIG = new StringBuilder(); try { for (Enumeration<NetworkInterface> en = NetworkInterface.getNetworkInterfaces(); en .hasMoreElements();) { NetworkInterface intf = en.nextElement(); for (Enumeration<InetAddress> enumIpAddr = intf.getInetAddresses(); enumIpAddr.hasMoreElements();) { InetAddress inetAddress = enumIpAddr.nextElement(); if (!inetAddress.isLoopbackAddress() && !inetAddress.isLinkLocalAddress() ... |
String | getLocalIP() get Local IP try { return InetAddress.getLocalHost().getHostAddress(); } catch (UnknownHostException e) { e.printStackTrace(); return null; |
String | getLocalIP() Looks up the IP number of the local host. String result; try { result = InetAddress.getLocalHost().getHostAddress(); } catch (UnknownHostException e) { result = "UNKNOWNIP"; return result; |
String | getLocalIp() get Local Ip try { Enumeration<NetworkInterface> ifs = NetworkInterface.getNetworkInterfaces(); while (ifs.hasMoreElements()) { NetworkInterface iface = ifs.nextElement(); if (iface.isUp()) { Enumeration<InetAddress> adds = iface.getInetAddresses(); while (adds.hasMoreElements()) { InetAddress addr = adds.nextElement(); ... |
String | getLocalIp() get Local Ip String localIp = ""; try { localIp = InetAddress.getLocalHost().getHostAddress(); if ("/".equals(System.getProperties().getProperty("file.separator"))) { Enumeration<?> netInterfaces = NetworkInterface.getNetworkInterfaces(); InetAddress ip = null; while (netInterfaces.hasMoreElements()) { NetworkInterface ni = (NetworkInterface) netInterfaces.nextElement(); ... |
String | getLocalIP() get Local IP if (cacheIP == null) { synchronized (cacheLock) { if (cacheIP == null) { try { cacheIP = getLocalIPByNetworkInterface(); } catch (Exception e) { if (cacheIP == null) { ... |
String | getLocalIp() get Local Ip try { for (Enumeration<NetworkInterface> e = NetworkInterface.getNetworkInterfaces(); e.hasMoreElements();) { NetworkInterface item = e.nextElement(); for (InterfaceAddress address : item.getInterfaceAddresses()) { if (address.getAddress() instanceof Inet4Address) { Inet4Address inet4Address = (Inet4Address) address.getAddress(); if (inet4Address.isLoopbackAddress()) { continue; ... |