Write a java program to find all the addresses of host [Example]

Java Program to find all the addresses of the host is given below.

 import java.net.*;

public class GetAllHostName{

    public static void main(String[] args){

try{

                InetAddress[] addresses  = InetAddress.getAllByName("www.google.com");    

                    for( InetAddress address:addresses ){

                            System.out.println(address);

                    }

                }catch(UnknownHostException e){

                    System.out.println(e);

                }

        }

}

Reactions

Post a Comment

0 Comments