String remoteHostName = remoteAddress.getHostName() InetAddress remoteAddress = InetAddress.getByName("") ("localHostAddress : "+localHostAddress) String localHostAddress = localAddress.getHostAddress() String localHostName = localAddress.getHostName() InetAddress localAddress = InetAddress.getLocalHost() Let us take a look at the code to get the IP Address and Host Name using InetAddress. InetAddress.getHostName(): Gets the host name for this IP address. InetAddress.getHostAddress(): Returns the IP address string in textual presentation. This is achieved by retrieving the name of the host from the system, then resolving that name into an InetAddress. InetAddress.getLocalHost(): Returns the address of the local host. GetByName() method determines the IP address of a host, given the host's name.Īll the following methods are static methods hence no need of object creation for InetAddress class. GetByName name method takes String as argument which is remote host name. InetAddress address = InetAddress.getByName("")
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |