public class InetAddress extends Object implements Serializable
Modifier and Type | Method and Description |
---|---|
boolean |
equals(Object obj)
Compares this object against the specified object
|
byte[] |
getAddress()
Returns the raw IP address of this InetAddress object
|
static InetAddress[] |
getAllByName(String host)
Determines all the hosts IP addresses, given the hostname;
|
static InetAddress |
getByAddress(byte[] ipAddress)
Equivalent to
getByAddress(null, ipAddress) . |
static InetAddress |
getByAddress(String hostName,
byte[] ipAddress)
Returns an
InetAddress corresponding to the given network-order
bytes ipAddress and scopeId . |
static InetAddress |
getByName(String host)
Determine the IP address, given the hostname
|
String |
getCanonicalHostName()
Returns the fully qualified hostname corresponding to this IP address.
|
String |
getHostAddress()
Returns IP address 'xxx.xxx.xxx.xxx'
|
String |
getHostName()
Returns the hostname for this address
|
static InetAddress |
getLocalHost()
Returns the localhost
|
int |
hashCode()
returns the hashcode for this IP address
|
boolean |
isAnyLocalAddress()
Returns whether this is a wildcard address or not.
|
boolean |
isLinkLocalAddress()
Returns whether this address is a link-local address or not.
|
boolean |
isLoopbackAddress()
Returns whether this address is a 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()
Checks if the InetAddress is a multicast address
IP Multicast Addresses (Class D) range from 224.0.0.0 to 239.255.255.255
|
boolean |
isSiteLocalAddress()
Returns whether this address is a site-local address or not.
|
String |
toString()
InetAddress -> String conversion
|
public boolean equals(Object obj)
public byte[] getAddress()
public static InetAddress[] getAllByName(String host) throws UnknownHostException
UnknownHostException
public static InetAddress getByName(String host) throws UnknownHostException
UnknownHostException
public String getHostAddress()
public String getHostName()
public static InetAddress getLocalHost() throws UnknownHostException
UnknownHostException
public int hashCode()
public boolean isMulticastAddress()
public String toString()
public String getCanonicalHostName()
public static InetAddress getByAddress(byte[] ipAddress) throws UnknownHostException
getByAddress(null, ipAddress)
. Handy for addresses with
no associated hostname.UnknownHostException
public static InetAddress getByAddress(String hostName, byte[] ipAddress) throws UnknownHostException
InetAddress
corresponding to the given network-order
bytes ipAddress
and scopeId
.
For an IPv4 address, the byte array must be of length 4.
For IPv6, the byte array must be of length 16. Any other length will cause an UnknownHostException
.
No reverse lookup is performed. The given hostName
(which may be null) is
associated with the new InetAddress
with no validation done.
(Note that numeric addresses such as "127.0.0.1"
are names for the
purposes of this API. Most callers probably want getAllByName(java.lang.String)
instead.)
UnknownHostException
- if ipAddress
is null or the wrong length.public boolean isAnyLocalAddress()
false
.true
if this instance represents a wildcard address,
false
otherwise.public boolean isLinkLocalAddress()
false
.
Valid IPv6 link-local addresses are FE80::0 through to FEBF:FFFF:FFFF:FFFF:FFFF:FFFF:FFFF:FFFF.
There are no valid IPv4 link-local addresses.
true
if this instance represents a link-local address,
false
otherwise.public boolean isLoopbackAddress()
false
. Valid IPv4 loopback
addresses are 127.d.d.d The only valid IPv6 loopback address is ::1.true
if this instance represents a loopback address,
false
otherwise.public boolean isMCGlobal()
false
.
Valid IPv6 link-global multicast addresses are FFxE:/112 where x is a set of flags, and the additional 112 bits make up the global multicast address space.
Valid IPv4 global multicast addresses are between: 224.0.1.0 to 238.255.255.255.
true
if this instance represents a global multicast
address, false
otherwise.public boolean isMCLinkLocal()
false
.
Valid IPv6 link-local multicast addresses are FFx2:/112 where x is a set of flags, and the additional 112 bits make up the link-local multicast address space.
Valid IPv4 link-local addresses are between: 224.0.0.0 to 224.0.0.255
true
if this instance represents a link-local multicast
address, false
otherwise.public boolean isMCNodeLocal()
false
.
Valid IPv6 node-local multicast addresses are FFx1:/112 where x is a set of flags, and the additional 112 bits make up the node-local multicast address space.
There are no valid IPv4 node-local multicast addresses.
true
if this instance represents a node-local multicast
address, false
otherwise.public boolean isMCOrgLocal()
false
.
Valid IPv6 organization-local multicast addresses are FFx8:/112 where x is a set of flags, and the additional 112 bits make up the organization-local multicast address space.
Valid IPv4 organization-local addresses are between: 239.192.0.0 to 239.251.255.255
true
if this instance represents a organization-local
multicast address, false
otherwise.public boolean isMCSiteLocal()
false
.
Valid IPv6 site-local multicast addresses are FFx5:/112 where x is a set of flags, and the additional 112 bits make up the site-local multicast address space.
Valid IPv4 site-local addresses are between: 239.252.0.0 to 239.255.255.255
true
if this instance represents a site-local multicast
address, false
otherwise.public boolean isSiteLocalAddress()
false
.
Valid IPv6 site-local addresses are FEC0::0 through to FEFF:FFFF:FFFF:FFFF:FFFF:FFFF:FFFF:FFFF.
There are no valid IPv4 site-local addresses.
true
if this instance represents a site-local address,
false
otherwise.