IPv6 have colon character, for example FF:00::EE
If concatenate URL String, IPv6 URL will like:
http://FF:00::EE:8888/a/b/c
Actually we want:
http://[FF:00::EE]:8888/a/b/c
Simply concatenate URL will cause error.
Take above line for example.
If not use square bracket, can’t identify “8888” is port or part of IPv6 address.
Please use the following code to create new URI
new URI("http", null,<host>, <port>, <additional URL>, null, null)
How to support both ipv4 and ipv6 address for JAVA code.
时间: 2024-10-12 07:34:27