IpUtils { public static List<String> getInetIps() { List<String> ipList = new LinkedList<>(); try { Enumeration<NetworkInterface> networkInterfaces = NetworkInterface.getNetworkInterfaces(); NetworkInterface networkInterface; Enumeration<InetAddress> inetAddresses; InetAddress inetAddress; String ip; while (networkInterfaces.hasMoreElements()) { networkInterface = networkInterfaces.nextElement(); inetAddresses = networkInterface.getInetAddresses(); while (inetAddresses.hasMoreElements()) { inetAddress = inetAddresses.nextElement(); if (inetAddress instanceof Inet4Address) { ip = inetAddress.getHostAddress(); ipList.add(ip); } } } } catch (SocketException e) { e.printStackTrace(); } return ipList; } private  IpUtils(); @SuppressWarnings("unchecked") static Map<String, String> getAllInfo(String ip); static String getCountry(String ip); static String getArea(String ip); static String getRegion(String ip); static String getCity(String ip); static String getIsp(String ip); static String getCounty(String ip); static String get(String ip, IpKey key); static String getInetIp(); static List<String> getInetIps();  }
@Test public void testGetInetIps(){ Assert.assertNotNull(IpUtils.getInetIps()); }