IPTools { public static boolean isIPv4Address(final String address) { return address != null && IPV4_PATTERN.matcher(address).matches(); } private  IPTools(); static boolean isIPv4Address(final String address); static boolean isIPv6StdAddress(final String address); static boolean isIPv6HexCompressedAddress(final String address); static boolean isIPv6Address(final String address); static InetAddress getLocalIPv4Address(); static ArrayList<InetAddress> getLocalIPv4Addresses(); static boolean isIpAddressLocalhost(InetAddress addr); static boolean isIpAddressLocalNetwork(InetAddress addr);  }
@Test public void testIsIPv4Address() { assertIPv4Address(getIPv4Addresses(), true); assertIPv4Address(getIPv6Addresses(), false); assertIPv4Address(getInvalidIpAddresses(), false); }