@Test public void getLocalIv4Address() throws Exception { HostUtil.getLocalIv4Address(); }
public static InetAddress getLocalIv4Address() { Enumeration<NetworkInterface> ns; try { ns = NetworkInterface.getNetworkInterfaces(); } catch (SocketException e) { log.warn(e); return null; } while (ns != null && ns.hasMoreElements()) { NetworkInterface networkInterface = ns.nextElement(); List<InetAddress> addresses = networkInterface.getInterfaceAddresses().stream() .filter(HostUtil::filter) .map(InterfaceAddress::getAddress) .collect(Collectors.toList()); if (addresses == null || addresses.size() == 0) continue; return addresses.get(0); } return null; }
HostUtil { public static InetAddress getLocalIv4Address() { Enumeration<NetworkInterface> ns; try { ns = NetworkInterface.getNetworkInterfaces(); } catch (SocketException e) { log.warn(e); return null; } while (ns != null && ns.hasMoreElements()) { NetworkInterface networkInterface = ns.nextElement(); List<InetAddress> addresses = networkInterface.getInterfaceAddresses().stream() .filter(HostUtil::filter) .map(InterfaceAddress::getAddress) .collect(Collectors.toList()); if (addresses == null || addresses.size() == 0) continue; return addresses.get(0); } return null; } }
HostUtil { public static InetAddress getLocalIv4Address() { Enumeration<NetworkInterface> ns; try { ns = NetworkInterface.getNetworkInterfaces(); } catch (SocketException e) { log.warn(e); return null; } while (ns != null && ns.hasMoreElements()) { NetworkInterface networkInterface = ns.nextElement(); List<InetAddress> addresses = networkInterface.getInterfaceAddresses().stream() .filter(HostUtil::filter) .map(InterfaceAddress::getAddress) .collect(Collectors.toList()); if (addresses == null || addresses.size() == 0) continue; return addresses.get(0); } return null; }  }
HostUtil { public static InetAddress getLocalIv4Address() { Enumeration<NetworkInterface> ns; try { ns = NetworkInterface.getNetworkInterfaces(); } catch (SocketException e) { log.warn(e); return null; } while (ns != null && ns.hasMoreElements()) { NetworkInterface networkInterface = ns.nextElement(); List<InetAddress> addresses = networkInterface.getInterfaceAddresses().stream() .filter(HostUtil::filter) .map(InterfaceAddress::getAddress) .collect(Collectors.toList()); if (addresses == null || addresses.size() == 0) continue; return addresses.get(0); } return null; }  static InetAddress getLocalIv4Address(); }
HostUtil { public static InetAddress getLocalIv4Address() { Enumeration<NetworkInterface> ns; try { ns = NetworkInterface.getNetworkInterfaces(); } catch (SocketException e) { log.warn(e); return null; } while (ns != null && ns.hasMoreElements()) { NetworkInterface networkInterface = ns.nextElement(); List<InetAddress> addresses = networkInterface.getInterfaceAddresses().stream() .filter(HostUtil::filter) .map(InterfaceAddress::getAddress) .collect(Collectors.toList()); if (addresses == null || addresses.size() == 0) continue; return addresses.get(0); } return null; }  static InetAddress getLocalIv4Address();  }