Hosts { public static Set<InetAddress> getAddresses() { Set<InetAddress> allAddresses = new LinkedHashSet<>(); Map<String, Set<InetAddress>> interfaceAddressMap = getNetworkInterfaceAddresses(false); for (Map.Entry<String, Set<InetAddress>> entry : interfaceAddressMap.entrySet()) { Set<InetAddress> addresses = entry.getValue(); if (!addresses.isEmpty()) { for (InetAddress address : addresses) { allAddresses.add(address); } } } return allAddresses; } private  Hosts(); static Map<String, Set<InetAddress>> getNetworkInterfaceAddresses(boolean includeLoopback); static Set<InetAddress> getAddresses(); static String getLocalHostName(); static String getLocalIp(); static final String PREFERED_ADDRESS_PROPERTY_NAME; }
@Test public void getAddresses() throws Exception { assertFalse(Hosts.getAddresses().isEmpty()); }