Returns the InetAddress having the given string representation. This deliberately avoids all nameservice lookups (e.g. no DNS). @param ipString String containing an IPv4 or IPv6 string literal, e.g. "192.168.0.1" or "2001:db8::1" @return InetAddress r
(String ipString)
| 143 | |
| 144 | |
| 145 | public static InetAddress forString(String ipString) { |
| 146 | byte[] addr = ipStringToBytes(ipString); |
| 147 | |
| 148 | // The argument was malformed, i.e. not an IP string literal. |
| 149 | if (addr == null) { |
| 150 | throw formatIllegalArgumentException("'%s' is not an IP string literal.", ipString); |
| 151 | } |
| 152 | return bytesToInetAddress(addr); |
| 153 | } |
| 154 | |
| 155 | /** |
| 156 | * Returns {@code true} if the supplied string is a valid IP string literal, {@code false} |
no test coverage detected