728x90
import java.net.InetAddress;
import java.net.UnknownHostException;
public class NSLookup {
public static void main(String[] args) {
InetAddress inetaddr[] = null;
try {
inetaddr = InetAddress.getAllByName("www.gougle.com");
} catch (UnknownHostException e) {
e.printStackTrace();
}
for (int i = 0; i < inetaddr.length; i++) {
System.out.println(inetaddr[i].getHostName()+"\n");
System.out.println(inetaddr[i].getHostAddress()+"\n");
System.out.println(inetaddr[i].toString()+"\n");
System.out.println("---------------");
}
}
}
---------- IO/NIO 책의 예제인거같기도....
728x90