The java.net.Inet6Address extended class is compatible with IPv6.
JavaDoc:
This class represents the Internet Protocol version 6 (IPv6) address. Defined in RFC 2373: IP Addressing Architecture Version 6.
Basically, if you execute InetAddress.getByName() or InetAddress.getByAddress() , the methods determine whether the name or address is the IPv4 or IPv6 name / address and return the extended Inet4Address / Inet6Address respectively.
As for InetAddress.getHostAddress() , it returns null . You will need java.net.Inet6Address.getHostAddress() to return the displayed IPv6 string address.
source share