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, returns an array of all the corresponding InetAddresses.
-
getByName(String)
- Returns a network address for the indicated host.
-
getHostAddress()
- Returns the IP address string "%d.%d.%d.%d"
-
getHostName()
- Gets the hostname for this address; also the key in the
hashtable.
-
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
hashtable.
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]. To be prepared for 64-bit
IP addresses n array of bytes is returned.
- Returns:
- raw IP address in network byte order.
getHostAddress
public String getHostAddress()
- Returns the IP address string "%d.%d.%d.%d"
- Returns:
- raw IP address in a string format
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 against.
- 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 all
addresses for a 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, returns 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