Inet6Address.java (getHostAddress): Fix textual representation of IPv6 address with embedded zeroes to conform to...
2004-11-18 Mattias Rehnberg <Mattias.Rehnberg@home.se> * java/net/Inet6Address.java (getHostAddress): Fix textual representation of IPv6 address with embedded zeroes to conform to RFC 2373. From-SVN: r90874
This commit is contained in:
parent
3d8532aa2a
commit
4fdb8244ae
2 changed files with 8 additions and 9 deletions
|
@ -207,18 +207,11 @@ public final class Inet6Address extends InetAddress
|
|||
for (int i = 0; i < 16; i += 2)
|
||||
{
|
||||
int x = ((ipaddress[i] & 0xFF) << 8) | (ipaddress[i + 1] & 0xFF);
|
||||
boolean empty = sbuf.length() == 0;
|
||||
|
||||
if (empty)
|
||||
{
|
||||
if (i > 0)
|
||||
sbuf.append("::");
|
||||
}
|
||||
else
|
||||
if (i > 0)
|
||||
sbuf.append(':');
|
||||
|
||||
if (x != 0 || i >= 14)
|
||||
sbuf.append(Integer.toHexString(x));
|
||||
sbuf.append(Integer.toHexString(x));
|
||||
}
|
||||
|
||||
return sbuf.toString();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue