InetAddress Test
import java.net.InetAddress;
public class InetAddressTest {
public InetAddressTest() {
try{
//내컴퓨터의 객체 생성
InetAddress ia1 = InetAddress.getLocalHost();
System.out.println("ia1(address) = "+ia1.getHostAddress());
System.out.println("ia1(name) = "+ia1.getHostName());
//
InetAddress ia2 = InetAddress.getByName("www.bycho.kr");
System.out.println("ia2(address) = "+ia2.getHostAddress());
System.out.println("ia2(name) = "+ia2.getHostName());
InetAddress ia3 = InetAddress.getByName("175.126.170.70");
System.out.println("ia3(address); = "+ia3.getHostAddress());
System.out.println("ia3(name); = "+ia3.getHostName());
InetAddress ia4[] = InetAddress.getAllByName("www.naver.com");
for(InetAddress ia:ia4){
System.out.println("ia4 = "+ia.getHostAddress());
}
}catch(Exception e){}
}
public static void main(String[] args) {
new InetAddressTest();
}
}