I used IPAddressUtil.isIPv6LiteralAddress (ipAddress)
method to validate IPv6, but this method fails for ipv6-address/prefix-length format (format is mentioned in RFC 4291 section 2.3) of IPV6.
Could anyone know any validators which validate " ipv6-address/prefix-length " format?
Legal representations of IPV6
You can use the Guava library, specifically using the com.google.common.net.InetAddresses
class, calling isInetAddress()
.
isInetAddress
public static boolean isInetAddress(String ipString)
Returns true if the supplied string is a valid IP string literal, false otherwise.
Parameters: ipString
- String to evaluated as an IP string literal
Returns: true
if the argument is a valid IP string literal