Class java.net.InetAddress
All Packages Class Hierarchy This Package Previous Next Index
Class java.net.InetAddress
java.lang.Object
|
+----java.net.InetAddress
- public final class InetAddress
- extends Object
A class that represents internet addresses.
-
equals(Object)
- Compares this object against the specified object.
-
getAddress()
- Returns the raw IP address in network byte order.
-
getAllByName(String)
-
Given a hostname, return an array of all the corresponding InetAddresses.
-
getByName(String)
- Returns a network address for the indicated host.
-
getHostName()
- Gets the hostname for this address; also the key in the above
hash table.
-
getLocalHost()
- Returns the local host.
-
hashCode()
- Returns a hashcode for this InetAddress.
-
toString()
- Converts the InetAddress to a String.
getHostName
public String getHostName()
- Gets the hostname for this address; also the key in the above
hash table.
If the host is equal to null, then this address refers to any
of the local machine's available network addresses.
getAddress
public byte[] getAddress()
- Returns the raw IP address in network byte order. The
highest order byte position is in addr[0]. An array of bytes
is returned so we are prepared for 64-bit IP addresses.
- Returns:
- raw IP address in network byte order.
hashCode
public int hashCode()
- Returns a hashcode for this InetAddress.
- Overrides:
- hashCode in class Object
equals
public boolean equals(Object obj)
- Compares this object against the specified object.
- Parameters:
- obj - the object to compare with
- Returns:
- true if the objects are the same; false otherwise.
- Overrides:
- equals in class Object
toString
public String toString()
- Converts the InetAddress to a String.
- Overrides:
- toString in class Object
getByName
public static synchronized InetAddress getByName(String host) throws UnknownHostException
- Returns a network address for the indicated host. A host name
of null refers to default address for the local machine. A local
cache is used to speed access to addresses. If a all
addresses for host are needed, use the getAllByName() method.
- Parameters:
- host - the specified host
- Throws: UnknownHostException
- If the address is unknown.
getAllByName
public static synchronized InetAddress[] getAllByName(String host) throws UnknownHostException
- Given a hostname, return an array of all the corresponding InetAddresses.
- Throws: UnknownHostException
- If the host name could not be resolved
getLocalHost
public static InetAddress getLocalHost() throws UnknownHostException
- Returns the local host.
- Throws: UnknownHostException
- If the host name could not be resolved
All Packages Class Hierarchy This Package Previous Next Index