[JAVA]HOST IP 구하기 소스

2013. 5. 20. 11:23개발자 공부방/JAVA

JAVA HOST IP 구하기 소스

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
import java.net.*;

public class test {

    public static void main(String[]args) {
        InetAddress ip = null;
        
        try{
            ip = InetAddress.getLocalHost();
            
            //HostName출력
            System.out.println("getLocalHost() : " + ip.getHostName());
            //IP출력
            System.out.println("getHostAddress() : " + ip.getHostAddress());
        }catch(UnknownHostException e){
            e.printStackTrace();
        }
    }
}




Mada in SLC

'개발자 공부방 > JAVA' 카테고리의 다른 글

JAVA 에서 FILE 유무 체크  (0) 2013.06.13
Signed Applet  (0) 2011.08.04