nofear
24-01-2003, 00:34
Bài này post theo yêu cầu của bạn anyway_tm. Chúc thành công.:D
---------------------------------------------------------------
import java.net.*;
public class AddrLookupApp {
public static void main (String[] args) {
try {
if (args.length!=1) {
System.out.println("Usage: java AddrLookupApp <Hostname>");
return;
}
//get the obj of InetAddress of the given hostname
InetAddress host = InetAddress.getByName(args[0]);
System.out.println("Host name: "+host.getHostName());
System.out.println("IP Address: "+host.getHostAddress());
}catch(UnknownHostException e) {
System.out.println("Address not found");
return;
}
}
}
---------------------------------------------------------------
import java.net.*;
public class AddrLookupApp {
public static void main (String[] args) {
try {
if (args.length!=1) {
System.out.println("Usage: java AddrLookupApp <Hostname>");
return;
}
//get the obj of InetAddress of the given hostname
InetAddress host = InetAddress.getByName(args[0]);
System.out.println("Host name: "+host.getHostName());
System.out.println("IP Address: "+host.getHostAddress());
}catch(UnknownHostException e) {
System.out.println("Address not found");
return;
}
}
}