a java program to prompt the user for a hostname and then looks up the IP Address for the hostname and displays the results
Aim: Write a java program to prompt the user for a hostname and then looks up the IP Address for the hostname and displays the results.
Program:
import java.lang.*;
import java.util.*;
import java.net.*;
class Address
{
public static void
main(String args[])
{
try
{
String
a=args[0];
InetAddress
i=InetAddress.getByName(a);
System.out.println(""+i.getHostAddress());
}
catch(Exception e)
{
System.out.println("Exception
caught");
}
}
}
Output:
Labels: Advanced Java Lab
0 Comments:
Post a Comment
Subscribe to Post Comments [Atom]
<< Home