rns "2001:db8::1" hp.getPort(); // returns 80 hp.toString(); // returns "[2001:db8::1]:80"
Here are some examples of recognized formats:
- example.com
- example.com:80
- 192.0.2.1
- 192.0.2.1:80
- [2001:db8::1] - {@link #getHostText()} omits brackets
- [2001:db8::1]:80 - {@link #getHostText()} omits brackets
- 2001:db8::1 - Use {@link #requireBracketsForIPv6()} to prohibit this
Note that this is not an exhaustive list, because these methods are only concerned with brackets, colons, and port numbers. Full validation of the host field (if desired) is the caller's responsibility.
@author Paul Marks
@since 10.0