Free Trial

Safari Books Online is a digital library providing on-demand subscription access to thousands of learning resources.

  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint
Share this Page URL
Help

12. java.net > InetAddress

Name

InetAddress

Synopsis

This class represents an Internet Protocol (IP) address. The class does not have a public constructor but instead supports static factory methods for obtaining InetAddress objects. getLocalHost( ) returns the InetAddress of the local computer. getByName( ) returns the InetAddress of a host specified by name. getAllByName( ) returns an array of InetAddress objects that represents all the available addresses for a host specified by name. getByAddress( ) returns an InetAddress that represents the IP address defined by the specified array of bytes.

Once you have obtained an InetAddress object, its instance methods provide various sorts of information about it. Two of the most important are getHostName( ) , which returns the hostname, and getAddress( ), which returns the IP address as an array of bytes, with the highest-order byte as the first element of the array. getHostAddress( ) returns the IP address formatted as a string rather than as an array of bytes. The various methods whose names begin with “is” determine whether the address falls into any of the named categories. The “isMC” methods are all related to multicast addresses.


  

You are currently reading a PREVIEW of this book.

                                                                                                                    

Get instant access to over $1 million worth of books and videos.

  

Start a Free Trial


  
  • Safari Books Online
  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint