@Test public void testGetLocalIp(){ String localIp = IpUtil.getLocalIp(); System.out.println(localIp); org.junit.Assert.assertNotNull(localIp); }
public static String getLocalIp() { Map<String,String> ips = getLocalIps(); List<String> faceNames = new ArrayList<String>(ips.keySet()); Collections.sort(faceNames); for(String name:faceNames){ if("lo".equals(name)){ continue; } String ip = ips.get(name); if(!StringUtils.isBlank(ip)){ return ip; } } return "127.0.0.1"; }
IpUtil { public static String getLocalIp() { Map<String,String> ips = getLocalIps(); List<String> faceNames = new ArrayList<String>(ips.keySet()); Collections.sort(faceNames); for(String name:faceNames){ if("lo".equals(name)){ continue; } String ip = ips.get(name); if(!StringUtils.isBlank(ip)){ return ip; } } return "127.0.0.1"; } }
IpUtil { public static String getLocalIp() { Map<String,String> ips = getLocalIps(); List<String> faceNames = new ArrayList<String>(ips.keySet()); Collections.sort(faceNames); for(String name:faceNames){ if("lo".equals(name)){ continue; } String ip = ips.get(name); if(!StringUtils.isBlank(ip)){ return ip; } } return "127.0.0.1"; }  }
IpUtil { public static String getLocalIp() { Map<String,String> ips = getLocalIps(); List<String> faceNames = new ArrayList<String>(ips.keySet()); Collections.sort(faceNames); for(String name:faceNames){ if("lo".equals(name)){ continue; } String ip = ips.get(name); if(!StringUtils.isBlank(ip)){ return ip; } } return "127.0.0.1"; }  static String intToIp(int i); static int ipToInt(final String addr); static long ipToLong(final String addr); static String longToIp(long i); static boolean isIp(String in); static Map<String,String> getLocalIps(); static String getLocalIp(); static String getSingleLocalIp(); static int ramdomAvailablePort(); static boolean availablePort(int port); static void main(String[] args); }
IpUtil { public static String getLocalIp() { Map<String,String> ips = getLocalIps(); List<String> faceNames = new ArrayList<String>(ips.keySet()); Collections.sort(faceNames); for(String name:faceNames){ if("lo".equals(name)){ continue; } String ip = ips.get(name); if(!StringUtils.isBlank(ip)){ return ip; } } return "127.0.0.1"; }  static String intToIp(int i); static int ipToInt(final String addr); static long ipToLong(final String addr); static String longToIp(long i); static boolean isIp(String in); static Map<String,String> getLocalIps(); static String getLocalIp(); static String getSingleLocalIp(); static int ramdomAvailablePort(); static boolean availablePort(int port); static void main(String[] args);  }