InetAddress GetAllByName() Example

returns an array of its IP addresses, based on the configured name service on the system.


InetAddressclass GetAllByName() method example. This example shows you how to use GetAllByName() method.This method returns an array of its IP addresses, based on the configured name service on the system.

Here is the code:-
/* 
 * @Program that returns an array of its IP addresses, based on the configured 
name service on the system.
 * GetAllByName.java 
 * Author:-RoseIndia Team
 * Date:-19-Jun-2008
 */

import java.net.*;

public class GetAllByName {

    public static void main(String[] argsthrows UnknownHostException {
        //returns an array of its IP addresses,
        InetAddress ia[] = InetAddress.getAllByName("girish-desktop");
        System.out.print("IP address is: ");
        for (int i = 0; i < ia.length; i++) {
            System.out.println(ia[i]);
        }
    }
}

Output of the program:-
 IP address is: girish-desktop/127.0.1.1

Post Comment
Name:
E-mail:
Contact no :
Comments:
  Refresh Image
Verify Image:
 
 
Your Comment's
 
 
 

HOME | COPYRIGHT | CONTACT US