public class InetAddressValidator extends Object implements Serializable
java.net.InetAddress
).
This class provides methods to validate a candidate IP address.
This class is a Singleton; you can retrieve the instance via the getInstance()
method.
Constructor and Description |
---|
InetAddressValidator() |
Modifier and Type | Method and Description |
---|---|
static InetAddressValidator |
getInstance()
Returns the singleton instance of this validator.
|
boolean |
isValid(String inetAddress)
Checks if the specified string is a valid IP address.
|
boolean |
isValidInet4Address(String inet4Address)
Validates an IPv4 address.
|
boolean |
isValidInet6Address(String inet6Address)
Validates an IPv6 address.
|
public static InetAddressValidator getInstance()
public boolean isValid(String inetAddress)
inetAddress
- the string to validatepublic boolean isValidInet4Address(String inet4Address)
inet4Address
- the IPv4 address to validatepublic boolean isValidInet6Address(String inet6Address)
inet6Address
- the IPv6 address to validate