Deriving the multipe addresses of a particular host

0 views
Skip to first unread message

nandu

unread,
Jan 17, 2007, 5:59:59 AM1/17/07
to Exam Bells !!! - Group for Sem exam preparation
//InetTest.java


import java.net.*;
import java.util.Scanner;
import java.io.*;

public class InetTest


{

public static void main(String s[])

{

Scanner input = new Scanner(System.in);
System.out.println("enter the address of the website(url)");
String sUrl= input.nextLine();

try
{
InetAddress[] addr = InetAddress.getAllByName(sUrl);

for (int i=0;i<addr.length;i++)
System.out.println(addr[i]);
System.out.println("\n\nTotal no: of servers = "
+addr.length);


}

catch(Exception e)
{
System.out.println("HAHAHA some problem, go home and take rest");

}

}
}

Reply all
Reply to author
Forward
0 new messages