I want to check if a string is an IPv4 or IPv6 address, but NOTHING else. Is there any way to accomplish this using standard java libs?
I know of:
- InetAddress.getByName(str) - but it accepts hostnames
- IPAddressUtil.isIPv4LiteralAddress(str) - but it is an internal class and will give compiler warnings
I know I could use regular expressions, but I prefer to use existing methods.