public final class

Inet6Address

extends InetAddress
java.lang.Object
   ↳ java.net.InetAddress
     ↳ java.net.Inet6Address

Class Overview

This class represents a 128 bit long IPv6 address.

Summary

Public Methods
static Inet6Address getByAddress(String host, byte[] addr, NetworkInterface nif)
Gets an IPv6 address instance according to the given host, addr and nif.
static Inet6Address getByAddress(String host, byte[] addr, int scope_id)
Constructs an IPv6 address according to the given host, addr and scope_id.
int getScopeId()
Gets the scope id as a number if this address is linked to an interface.
NetworkInterface getScopedInterface()
Gets the network interface if this address is instanced with a scoped network interface.
boolean isAnyLocalAddress()
Returns whether this address is a unspecified wildcard address "::" or not.
boolean isIPv4CompatibleAddress()
Returns whether this address is IPv4 compatible or not.
boolean isLinkLocalAddress()
Returns whether this address is a link-local address or not.
boolean isLoopbackAddress()
Returns whether this address is the loopback address or not.
boolean isMCGlobal()
Returns whether this address is a global multicast address or not.
boolean isMCLinkLocal()
Returns whether this address is a link-local multicast address or not.
boolean isMCNodeLocal()
Returns whether this address is a node-local multicast address or not.
boolean isMCOrgLocal()
Returns whether this address is a organization-local multicast address or not.
boolean isMCSiteLocal()
Returns whether this address is a site-local multicast address or not.
boolean isMulticastAddress()
Returns whether this address is an IP multicast address or not.
boolean isSiteLocalAddress()
Returns whether this address is a site-local address or not.
String toString()
Returns a string containing a concise, human-readable description of this IP address.
[Expand]
Inherited Methods
From class java.net.InetAddress
From class java.lang.Object

Public Methods

public static Inet6Address getByAddress (String host, byte[] addr, NetworkInterface nif)

Since: API Level 1

Gets an IPv6 address instance according to the given host, addr and nif. scope_id is set according to the given nif and the addr type (for example site-local or link-local).

Parameters
host the hostname associated with the address.
addr the network address.
nif the network interface that this address is associated with.
Returns
  • the Inet6Address instance representing the IP address.
Throws
UnknownHostException if the address is null or has an invalid length or the interface doesn't have a numeric scope id for the given address type.

public static Inet6Address getByAddress (String host, byte[] addr, int scope_id)

Since: API Level 1

Constructs an IPv6 address according to the given host, addr and scope_id.

Parameters
host the host name associated with the address.
addr the network address.
scope_id the scope id for link- or site-local addresses.
Returns
  • the Inet6Address instance representing the IP address.
Throws
UnknownHostException if the address is null or has an invalid length.

public int getScopeId ()

Since: API Level 1

Gets the scope id as a number if this address is linked to an interface. Otherwise returns 0.

Returns
  • the scope_id of this address or 0 when not linked with an interface.

public NetworkInterface getScopedInterface ()

Since: API Level 1

Gets the network interface if this address is instanced with a scoped network interface. Otherwise returns null.

Returns
  • the scoped network interface of this address.

public boolean isAnyLocalAddress ()

Since: API Level 1

Returns whether this address is a unspecified wildcard address "::" or not.

Returns
  • true if this instance represents a wildcard address, false otherwise.

public boolean isIPv4CompatibleAddress ()

Since: API Level 1

Returns whether this address is IPv4 compatible or not. An IPv4 compatible address is prefixed with 96 bits of 0's. The last 32-bits are varied corresponding with the 32-bit IPv4 address space.

Returns
  • true if this instance represents an IPv4 compatible address, false otherwise.

public boolean isLinkLocalAddress ()

Since: API Level 1

Returns whether this address is a link-local address or not. A valid IPv6 link-local address is prefixed with 1111111010.

Returns
  • true if this instance represents a link-local address, false otherwise.

public boolean isLoopbackAddress ()

Since: API Level 1

Returns whether this address is the loopback address or not. The only valid IPv6 loopback address is "::1".

Returns
  • true if this instance represents the loopback address, false otherwise.

public boolean isMCGlobal ()

Since: API Level 1

Returns whether this address is a global multicast address or not. A valid IPv6 global multicast address is 11111111xxxx1110 or FF0E hex.

Returns
  • true if this instance represents a global multicast address, false otherwise.

public boolean isMCLinkLocal ()

Since: API Level 1

Returns whether this address is a link-local multicast address or not. A valid IPv6 link-local multicast address is prefixed with 11111111xxxx0010.

Returns
  • true if this instance represents a link-local multicast address, false otherwise.

public boolean isMCNodeLocal ()

Since: API Level 1

Returns whether this address is a node-local multicast address or not. A valid IPv6 node-local multicast address is prefixed with 11111111xxxx0001.

Returns
  • true if this instance represents a node-local multicast address, false otherwise.

public boolean isMCOrgLocal ()

Since: API Level 1

Returns whether this address is a organization-local multicast address or not. A valid IPv6 org-local multicast address is prefixed with 11111111xxxx1000.

Returns
  • true if this instance represents a org-local multicast address, false otherwise.

public boolean isMCSiteLocal ()

Since: API Level 1

Returns whether this address is a site-local multicast address or not. A valid IPv6 site-local multicast address is prefixed with 11111111xxxx0101.

Returns
  • true if this instance represents a site-local multicast address, false otherwise.

public boolean isMulticastAddress ()

Since: API Level 1

Returns whether this address is an IP multicast address or not. Valid IPv6 multicast addresses are binary prefixed with 11111111 or FF (hex).

Returns
  • true if this address is in the multicast group, false otherwise.

public boolean isSiteLocalAddress ()

Since: API Level 1

Returns whether this address is a site-local address or not. A valid IPv6 site-local address is prefixed with 1111111011.

Returns
  • true if this instance represents a site-local address, false otherwise.

public String toString ()

Since: API Level 1

Returns a string containing a concise, human-readable description of this IP address.

Returns
  • the description, as host/address.