Class java.net.InetAddress
All Packages  Class Hierarchy  This Package  Previous  Next  Index

Class java.net.InetAddress

Object
   |
   +----java.net.InetAddress

public final class InetAddress
extends Object
implements Serializable
This class represents an Internet Protocol (IP) address.

Applications should use the methods getLocalHost, getByName, or getAllByName to create a new InetAddress instance.

Version:
1.46, 07/27/98
Author:
Chris Warth
Since:
JDK1.0
See Also:
getAllByName(java.lang.String), getByName(java.lang.String), getLocalHost()

Method Index

 o equals(Object)
Compares this object against the specified object.
 o getAddress()
Returns the raw IP address of this InetAddress object.
 o getAllByName(String)
Determines all the IP addresses of a host, given the host's name.
 o getByName(String)
Determines the IP address of a host, given the host's name.
 o getHostAddress()
Returns the IP address string "%d.%d.%d.%d"
 o getHostName()
Returns the fully qualified host name for this address.
 o getLocalHost()
Returns the local host.
 o hashCode()
Returns a hashcode for this IP address.
 o isMulticastAddress()
Utility routine to check if the InetAddress is a IP multicast address.
 o toString()
Converts this IP address to a String.

Methods

 o equals
public boolean equals(Object obj)
Compares this object against the specified object. The result is true if and only if the argument is not null and it represents the same IP address as this object.

Two instances of InetAddress represent the same IP address if the length of the byte arrays returned by getAddress is the same for both, and each of the array components is the same for the byte arrays.

Parameters:
obj - the object to compare against.
Returns:
true if the objects are the same; false otherwise.
Overrides:
equals in class Object
Since:
JDK1.0
See Also:
getAddress()
 o getAddress
public byte[] getAddress()
Returns the raw IP address of this InetAddress object. The result is in network byte order: the highest order byte of the address is in getAddress()[0].

Returns:
the raw IP address of this object.
Since:
JDK1.0
 o getAllByName
public static java.net.InetAddress[] getAllByName(String host) throws UnknownHostException
Determines all the IP addresses of a host, given the host's name. The host name can either be a machine name, such as "java.sun.com", or a string representing its IP address, such as "206.26.48.100".

Parameters:
host - the name of the host.
Returns:
an array of all the IP addresses for a given host name.
Throws: UnknownHostException
if no IP address for the host could be found.
Since:
JDK1.0
 o getByName
public static java.net.InetAddress getByName(String host) throws UnknownHostException
Determines the IP address of a host, given the host's name. The host name can either be a machine name, such as "java.sun.com", or a string representing its IP address, such as "206.26.48.100".

Parameters:
host - the specified host, or null for the local host.
Returns:
an IP address for the given host name.
Throws: UnknownHostException
if no IP address for the host could be found.
Since:
JDK1.0
 o getHostAddress
public java.lang.String getHostAddress()
Returns the IP address string "%d.%d.%d.%d"

Returns:
raw IP address in a string format
Since:
JDK1.1
 o getHostName
public java.lang.String getHostName()
Returns the fully qualified host name for this address. If the host is equal to null, then this address refers to any of the local machine's available network addresses.

Returns:
the fully qualified host name for this address.
Since:
JDK1.0
 o getLocalHost
public static java.net.InetAddress getLocalHost() throws UnknownHostException
Returns the local host.

Returns:
the IP address of the local host.
Throws: UnknownHostException
if no IP address for the host could be found.
Since:
JDK1.0
 o hashCode
public int hashCode()
Returns a hashcode for this IP address.

Returns:
a hash code value for this IP address.
Overrides:
hashCode in class Object
Since:
JDK1.0
 o isMulticastAddress
public boolean isMulticastAddress()
Utility routine to check if the InetAddress is a IP multicast address. IP multicast address is a Class D address i.e first four bits of the address are 1110.

Since:
JDK1.1
 o toString
public java.lang.String toString()
Converts this IP address to a String.

Returns:
a string representation of this IP address.
Overrides:
toString in class Object
Since:
JDK1.0

All Packages  Class Hierarchy  This Package  Previous  Next  Index