java.net
public class InetAddress extends Object implements Serializable
This class fulfills the function of the C style functions gethostname(), gethostbyname(), and gethostbyaddr(). It resolves Internet DNS names into their corresponding numeric addresses and vice versa.
UNKNOWN: This class is not final since JDK 1.4
Method Summary | |
---|---|
boolean | equals(Object obj)
Tests this address for equality against another InetAddress. |
byte[] | getAddress()
Returns the IP address of this object as a byte array.
|
static InetAddress[] | getAllByName(String hostname)
Returns an array of InetAddress objects representing all the host/ip
addresses of a given host, given the host's name. |
static InetAddress | getByAddress(byte[] addr)
Returns an InetAddress object given the raw IP address.
|
static InetAddress | getByAddress(String host, byte[] addr)
Creates an InetAddress based on the provided host name and IP address.
|
static InetAddress | getByName(String hostname)
Returns an InetAddress object representing the IP address of the given
hostname. |
String | getCanonicalHostName()
Returns the canonical hostname represented by this InetAddress
|
String | getHostAddress()
Returns the IP address of this object as a String.
|
String | getHostName()
Returns the hostname for this address. |
static InetAddress | getLocalHost()
Returns an InetAddress object representing the address of the current
host.
|
int | hashCode()
Returns a hash value for this address. |
boolean | isAnyLocalAddress()
Utility routine to check if the InetAddress in a wildcard address
This method cannot be abstract for backward compatibility reasons. |
boolean | isLinkLocalAddress()
Utility routine to check if InetAddress is a link local address
This method cannot be abstract for backward compatibility reasons. |
boolean | isLoopbackAddress()
Utility routine to check if the InetAddress is a loopback address
This method cannot be abstract for backward compatibility reasons. |
boolean | isMCGlobal()
Utility routine to check if InetAddress is a global multicast address
This method cannot be abstract for backward compatibility reasons. |
boolean | isMCLinkLocal()
Utility routine to check if InetAddress is a link local multicast address.
|
boolean | isMCNodeLocal()
Utility routine to check if InetAddress is a node local multicast address.
|
boolean | isMCOrgLocal()
Utility routine to check if InetAddress is a organization local
multicast address.
|
boolean | isMCSiteLocal()
Utility routine to check if InetAddress is a site local multicast address.
|
boolean | isMulticastAddress()
Returns true if this address is a multicast address, false otherwise.
|
boolean | isSiteLocalAddress()
Utility routine to check if InetAddress is a site local address
This method cannot be abstract for backward compatibility reasons. |
String | toString()
Converts this address to a String. |
Parameters: obj The address to test for equality
Returns: true if the passed in object's address is equal to this one's, false otherwise
Returns: IP address
Parameters: hostname The name of the desired host, or null for the local loopback address.
Returns: All addresses of the host as an array of InetAddress objects.
Throws: UnknownHostException If no IP address for the host could be found SecurityException If a security manager exists and its checkConnect method doesn't allow the operation
Parameters: addr The IP address to create the InetAddress object from
Throws: UnknownHostException If IP address has illegal length
Since: 1.4
Parameters: host The hostname of the InetAddress object to create addr The IP address to create the InetAddress object from
Throws: UnknownHostException If IP address is of illegal length
Since: 1.4
Parameters: hostname The name of the desired host, or null for the local loopback address.
Returns: The address of the host as an InetAddress object.
Throws: UnknownHostException If no IP address for the host could be found SecurityException If a security manager exists and its checkConnect method doesn't allow the operation
Since: 1.4
This method cannot be abstract for backward compatibility reasons. By default it always throws {@link UnsupportedOperationException} unless overridden.
Returns: The IP address of this object in String form
Since: 1.0.2
Returns: The hostname for this address
Returns: The local host's address
Throws: UnknownHostException If no IP address for the host could be found
Returns: A hash value for this address.
This method cannot be abstract for backward compatibility reasons. By default it always throws {@link UnsupportedOperationException} unless overridden.
Since: 1.4
This method cannot be abstract for backward compatibility reasons. By default it always throws {@link UnsupportedOperationException} unless overridden.
Since: 1.4
This method cannot be abstract for backward compatibility reasons. By default it always throws {@link UnsupportedOperationException} unless overridden.
Since: 1.4
This method cannot be abstract for backward compatibility reasons. By default it always throws {@link UnsupportedOperationException} unless overridden.
Since: 1.4
This method cannot be abstract for backward compatibility reasons. By default it always throws {@link UnsupportedOperationException} unless overridden.
Since: 1.4
This method cannot be abstract for backward compatibility reasons. By default it always throws {@link UnsupportedOperationException} unless overridden.
Since: 1.4
This method cannot be abstract for backward compatibility reasons. By default it always throws {@link UnsupportedOperationException} unless overridden.
Since: 1.4
This method cannot be abstract for backward compatibility reasons. By default it always throws {@link UnsupportedOperationException} unless overridden.
Since: 1.4
This method cannot be abstract for backward compatibility reasons. By default it always throws {@link UnsupportedOperationException} unless overridden.
Returns: true if mulitcast, false if not
Since: 1.1
This method cannot be abstract for backward compatibility reasons. By default it always throws {@link UnsupportedOperationException} unless overridden.
Since: 1.4
Returns: This address in String form