Find an IP Address by Name

Find the IP address of a server that you know, for example:

Java, as usual, provides a very easy mechanism to retrieve the IP address of a server that you know.

import*;public class FindIPByName {       static String url = "";   public static void main(String[] args) {            if (args.length == 1)         url = args[0];      try       {         System.out.println(InetAddress.getByName(url));      }catch( uhe)      {         System.out.println("Unknown host: " + url);      }    }}/*

Expected output:

[[email protected]]# java FindIPByName[[email protected]]#[[email protected]]# java FindIPByName*/
Share the Post:
Share on facebook
Share on twitter
Share on linkedin


Recent Articles: