IpUtils { public static String[] splitIpAddr(String ip) { return StringUtil.splitRemoveEmpty("\\s*\\.\\s*", ip); }  static String getIp(SocketAddress socketAddress); static boolean isValidIpFormat(String ip); static boolean isPort(String str); static InetAddress getFistNonLocalIpv4ServerAddress(); static InetAddress getFistNonLocalIpv4ServerAddress(String ipPrefixPrefer); static boolean isLocal(String host); static List<HostPort> parseAsHostPorts(String addressDesc); static List<InetSocketAddress> parse(String addressDesc); static InetSocketAddress parseSingle(String singleAddress); static Pair<String, Integer> parseSingleAsPair(String singleAddress); static String[] splitIpAddr(String ip);  }
@Test public void testIpSplit() { String ip = "10"; Assert.assertEquals(1, IpUtils.splitIpAddr(ip).length); Assert.assertEquals(ip, IpUtils.splitIpAddr(ip)[0]); ip = "10.26"; Assert.assertEquals(2, IpUtils.splitIpAddr(ip).length); Assert.assertEquals("10", IpUtils.splitIpAddr(ip)[0]); Assert.assertEquals("26", IpUtils.splitIpAddr(ip)[1]); }