- 01
- 02
- 03
- 04
- 05
- 06
- 07
- 08
- 09
- 10
- 11
- 12
- 13
- 14
- 15
- 16
url = new URL("http://[FF01:0:0:0:0:0:0:0101]");
String originalHostName = url.getHost();
System.out.println(originalHostName);
if (originalHostName.startsWith("[") && originalHostName.endsWith("]")) {
i1 = originalHostName.indexOf("[");
originalHostName = originalHostName.substring(i1 + 1);
i2 = originalHostName.lastIndexOf("]");
originalHostName = originalHostName.substring(0, i2);
if (IPV6REGEX.matcher(originalHostName).matches()) {
System.out.println(url + " is a ipv6 address");
String hostName = InetAddress.getByName(originalHostName).getHostAddress().toLowerCase();
if (hostName.contains(":")) {
hostName = "[" + hostName + "]";
}
}
}
Взято отсюда: http://www.pretechsol.com/2013/05/ipv6-java-regular-expression-example.html#.VBtooLn69B0
Lokich 21.09.2014 07:03 # 0
0rt 22.09.2014 01:36 # 0