Welcome to the World of Programming

Welcome to the World of Programming

Search this blog

Finding IP Address of a Domain Name

import java.net.*;
import java.io.*;

public class IPofHost{
    public static void main(String args[])throws Exception{
        String hostname;
        System.out.print("Enter Domain Name :");
        BufferedReader in=new BufferedReader(new InputStreamReader(System.in));
        hostname=in.readLine();
        try{
            InetAddress ip=InetAddress.getByName(hostname);
            System.out.println("IP Address :"+ip);
        }
        catch(Exception e){
            System.out.println("Host Not Found");
        }
    }
}

No comments:

Post a Comment