5.3 Miscellaneous Classes5.3.1 InetAddress Classpublic final class InetAddress extends Object implements Serializable Object InetAddress InterfacesSerializable An InetAddress object represents an IP address. The InetAddress class provides no public constructors. An InetAddress object is obtained from one of the static InetAddress object creation methods in this class. Static InetAddress Object Creation Methods
getAllByName() returns an array of InetAddress objects containing all of the IP addresses corresponding to the specified host name. The specified host name can either be a machine name, like "www.wrox.com", or an IP address such as "204.148.170.3". getByName() returns an InetAddress object representing the primary IP address corresponding to the specified host name. getLocalHost() returns an InetAddress object containing the IP address of the local host machine. equals() Method
equals() overrides the equals() method from the Object class and returns true if Object obj is an InetAddress and contains the same IP address as the invoking InetAddress object. hashCode() Method
hashCode() overrides the hashCode() method from the Object class and returns a hash code for the invoking InetAddress object. Methods to Return InetAddress Properties
getAddress() returns a byte array containing the IP address of the invoking InetAddress object. getHostAddress() returns a String representation of the IP address of the invoking InetAddress object. getHostName() method attempts to return the host name associated with the IP address contained by the invoking InetAddress object. This method returns a String representation of the IP address if it cannot determine the host name. isMulticastAddress() returns true if the invoking InetAddress object represents a multicast IP address. toString() Method
toString() overrides the toString() method from the Object class and returns a String representation of the IP address associated with the invoking InetAddress object.
|