@Test public void getIpListByRegistry() throws Exception { }
public static List<InetSocketAddress> getIpListByRegistry(String registryIp) { List<String[]> ips = new ArrayList<String[]>(); String defaultPort = null; String[] srcIps = registryIp.split(","); for (String add : srcIps) { int a = add.indexOf(": if (a > -1) { add = add.substring(a + 3); } String[] s1 = add.split(":"); if (s1.length > 1) { if (defaultPort == null && s1[1] != null && s1[1].length() > 0) { defaultPort = s1[1]; } ips.add(new String[] { s1[0], s1[1] }); } else { ips.add(new String[] { s1[0], defaultPort }); } } List<InetSocketAddress> ads = new ArrayList<InetSocketAddress>(); for (int j = 0; j < ips.size(); j++) { String[] ip = ips.get(j); try { InetSocketAddress address = new InetSocketAddress(ip[0], Integer.parseInt(ip[1] == null ? defaultPort : ip[1])); ads.add(address); } catch (Exception ignore) { } } return ads; }
NetUtils { public static List<InetSocketAddress> getIpListByRegistry(String registryIp) { List<String[]> ips = new ArrayList<String[]>(); String defaultPort = null; String[] srcIps = registryIp.split(","); for (String add : srcIps) { int a = add.indexOf(": if (a > -1) { add = add.substring(a + 3); } String[] s1 = add.split(":"); if (s1.length > 1) { if (defaultPort == null && s1[1] != null && s1[1].length() > 0) { defaultPort = s1[1]; } ips.add(new String[] { s1[0], s1[1] }); } else { ips.add(new String[] { s1[0], defaultPort }); } } List<InetSocketAddress> ads = new ArrayList<InetSocketAddress>(); for (int j = 0; j < ips.size(); j++) { String[] ip = ips.get(j); try { InetSocketAddress address = new InetSocketAddress(ip[0], Integer.parseInt(ip[1] == null ? defaultPort : ip[1])); ads.add(address); } catch (Exception ignore) { } } return ads; } }
NetUtils { public static List<InetSocketAddress> getIpListByRegistry(String registryIp) { List<String[]> ips = new ArrayList<String[]>(); String defaultPort = null; String[] srcIps = registryIp.split(","); for (String add : srcIps) { int a = add.indexOf(": if (a > -1) { add = add.substring(a + 3); } String[] s1 = add.split(":"); if (s1.length > 1) { if (defaultPort == null && s1[1] != null && s1[1].length() > 0) { defaultPort = s1[1]; } ips.add(new String[] { s1[0], s1[1] }); } else { ips.add(new String[] { s1[0], defaultPort }); } } List<InetSocketAddress> ads = new ArrayList<InetSocketAddress>(); for (int j = 0; j < ips.size(); j++) { String[] ip = ips.get(j); try { InetSocketAddress address = new InetSocketAddress(ip[0], Integer.parseInt(ip[1] == null ? defaultPort : ip[1])); ads.add(address); } catch (Exception ignore) { } } return ads; }  }
NetUtils { public static List<InetSocketAddress> getIpListByRegistry(String registryIp) { List<String[]> ips = new ArrayList<String[]>(); String defaultPort = null; String[] srcIps = registryIp.split(","); for (String add : srcIps) { int a = add.indexOf(": if (a > -1) { add = add.substring(a + 3); } String[] s1 = add.split(":"); if (s1.length > 1) { if (defaultPort == null && s1[1] != null && s1[1].length() > 0) { defaultPort = s1[1]; } ips.add(new String[] { s1[0], s1[1] }); } else { ips.add(new String[] { s1[0], defaultPort }); } } List<InetSocketAddress> ads = new ArrayList<InetSocketAddress>(); for (int j = 0; j < ips.size(); j++) { String[] ip = ips.get(j); try { InetSocketAddress address = new InetSocketAddress(ip[0], Integer.parseInt(ip[1] == null ? defaultPort : ip[1])); ads.add(address); } catch (Exception ignore) { } } return ads; }  static boolean isInvalidPort(int port); static boolean isRandomPort(int port); static int getAvailablePort(String host, int port); static int getAvailablePort(String host, int port, int maxPort); static boolean isLocalHost(String host); static boolean isAnyHost(String host); static boolean isIPv4Host(String host); static boolean isHostInNetworkCard(String host); static String getLocalIpv4(); static InetAddress getLocalAddress(); static String toAddressString(InetSocketAddress address); static String toIpString(InetSocketAddress address); static String getLocalHostByRegistry(String registryIp); static List<InetSocketAddress> getIpListByRegistry(String registryIp); static boolean isMatchIPByPattern(String whiteList, String localIP); static String connectToString(InetSocketAddress local, InetSocketAddress remote); static String channelToString(SocketAddress local1, SocketAddress remote1); static boolean canTelnet(String ip, int port, int timeout); static void joinMulticastGroup(MulticastSocket multicastSocket, InetAddress multicastAddress); static void setInterface(MulticastSocket multicastSocket, boolean preferIpv6); }
NetUtils { public static List<InetSocketAddress> getIpListByRegistry(String registryIp) { List<String[]> ips = new ArrayList<String[]>(); String defaultPort = null; String[] srcIps = registryIp.split(","); for (String add : srcIps) { int a = add.indexOf(": if (a > -1) { add = add.substring(a + 3); } String[] s1 = add.split(":"); if (s1.length > 1) { if (defaultPort == null && s1[1] != null && s1[1].length() > 0) { defaultPort = s1[1]; } ips.add(new String[] { s1[0], s1[1] }); } else { ips.add(new String[] { s1[0], defaultPort }); } } List<InetSocketAddress> ads = new ArrayList<InetSocketAddress>(); for (int j = 0; j < ips.size(); j++) { String[] ip = ips.get(j); try { InetSocketAddress address = new InetSocketAddress(ip[0], Integer.parseInt(ip[1] == null ? defaultPort : ip[1])); ads.add(address); } catch (Exception ignore) { } } return ads; }  static boolean isInvalidPort(int port); static boolean isRandomPort(int port); static int getAvailablePort(String host, int port); static int getAvailablePort(String host, int port, int maxPort); static boolean isLocalHost(String host); static boolean isAnyHost(String host); static boolean isIPv4Host(String host); static boolean isHostInNetworkCard(String host); static String getLocalIpv4(); static InetAddress getLocalAddress(); static String toAddressString(InetSocketAddress address); static String toIpString(InetSocketAddress address); static String getLocalHostByRegistry(String registryIp); static List<InetSocketAddress> getIpListByRegistry(String registryIp); static boolean isMatchIPByPattern(String whiteList, String localIP); static String connectToString(InetSocketAddress local, InetSocketAddress remote); static String channelToString(SocketAddress local1, SocketAddress remote1); static boolean canTelnet(String ip, int port, int timeout); static void joinMulticastGroup(MulticastSocket multicastSocket, InetAddress multicastAddress); static void setInterface(MulticastSocket multicastSocket, boolean preferIpv6); static final String ANYHOST; static final Pattern IPV4_PATTERN; }