Returns the string representation of an InetAddress suitable for inclusion in a URI. For IPv4 addresses, this is identical to InetAddress#getHostAddress(), but for IPv6 addresses it compresses zeroes and surrounds the text with square brackets; for example "[2001:db8::1]"
(InetAddress ip)
| 434 | * @return {@code String} containing URI-safe string literal |
| 435 | */ |
| 436 | public static String toUriString(InetAddress ip) { |
| 437 | if (ip instanceof Inet6Address) { |
| 438 | return "[" + toAddrString(ip) + "]"; |
| 439 | } |
| 440 | return toAddrString(ip); |
| 441 | } |
| 442 | |
| 443 | /** |
| 444 | * Returns an InetAddress representing the literal IPv4 or IPv6 host portion of a URL, encoded in |