MCPcopy
hub / github.com/google/guava / toUriString

Method toUriString

guava/src/com/google/common/net/InetAddresses.java:585–590  ·  view source on GitHub ↗

Returns the string representation of an {@link InetAddress} suitable for inclusion in a URI. <p>For IPv4 addresses, this is identical to {@link InetAddress#getHostAddress()}, but for IPv6 addresses it compresses zeroes and surrounds the text with square brackets; for example {@code "[2001:db8::1]"}

(InetAddress ip)

Source from the content-addressed store, hash-verified

583 * @return {@code String} containing URI-safe string literal
584 */
585 public static String toUriString(InetAddress ip) {
586 if (ip instanceof Inet6Address) {
587 return "[" + toAddrString(ip) + "]";
588 }
589 return toAddrString(ip);
590 }
591
592 /**
593 * Returns an InetAddress representing the literal IPv4 or IPv6 host portion of a URL, encoded in

Callers 3

fromValidMethod · 0.95
testToUriStringIPv4Method · 0.95
testToUriStringIPv6Method · 0.95

Calls 1

toAddrStringMethod · 0.95

Tested by 2

testToUriStringIPv4Method · 0.76
testToUriStringIPv6Method · 0.76