Package java.net |
![]() Previous |
![]() Java API |
![]() Index |
![]() Next |
public final class java.net.InetAddress extends java.lang.Object { // Methods public boolean equals(Object obj); public byte[] getAddress(); public static InetAddress[] getAllByName(String host); public static InetAddress getByName(String host); public String getHostName(); public static InetAddress getLocalHost(); public int hashCode(); public String toString(); }
This class represents an Internet Protocol (IP) address.
Applications should use the methods getLocalHost , getByName , or getAllByName to create a new InetAddress instance.
public boolean equals(Object obj)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.
Return Value:
Returns true if the objects are the same; false otherwise.
Parameter Description obj the object to compare against Overrides:
equals in class Object .
public byte[] getAddress()Determines the raw IP address of this InetAddress object. The result is in network byte order: the highest order byte of the address is in get-Address()[0].
Return Value:
Returns the raw IP address of this object.
public static InetAddress[] getAllByName(String host)throws UnknownHostExceptionReturn Value:
Returns an array of all the IP addresses for a given host name.
Parameter Description host the name of the host Throw:
If no IP address for the host could be found.
public static InetAddress getByName(String host)throws UnknownHostExceptionDetermines 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".
Return Value:
Returns an IP address for the given host name.
Parameter Description host the specified host, or null for the local host Throw:
If no IP address for the host could be found.
public String getHostName()Return Value:
Returns the host name for this IP address.
public static InetAddress getLocalHost()throws UnknownHostExceptionReturn Value:
Returns the IP address of the local host.
Throw:
If no IP address for the host could be found.
public int hashCode()Return Value:
Returns a hash code value for this IP address.
Overrides:
hashCode in class Object .
public String toString()Return Value:
Returns a string representation of this IP address.
Overrides:
toString in class Object .