336x280(권장), 300x250(권장), 250x250, 200x200 크기의 광고 코드만 넣을 수 있습니다.

package InetAddress;

import java.net.InetAddress;
import java.net.UnknownHostException;

public class Inetaddress {
    public static void main(String[] args)throws UnknownHostException{
        String host="www.naver.com";
        InetAddress inet=InetAddress.getByName(host);
                // (IP주소를 표현한 클래스) 클래스는 static이므로 객체 생성없이 바로 접근한다.   
        String ip=inet.getHostAddress();
       
        System.out.println("IP : " + ip);
       

//만약 여러개의 IP를 사용할 경우

        InetAddress[] ips=InetAddress.getAllByName(host);
        System.out.println("------------------------------------------");
        for(InetAddress n : ips){http://inchoryang.tistory.com/admin/entry/post
            System.out.println(n.getHostAddress());
           
        }
    }
}

'Java' 카테고리의 다른 글

InputStream  (0) 2014.12.26
DataInputStream / DataOutputStream  (0) 2014.12.25
Multi Chatting  (0) 2014.12.25
class StringBuilder  (0) 2014.12.24
Runtime.getRuntime().exec()  (0) 2014.12.24
Posted by af334