In Java, you can use InetAddress.getLocalHost()
to get the Ip Address of the current Server running the Java app.
package com.mkyong; import java.net.InetAddress; import java.net.UnknownHostException; public class Test { public static void main(String[] args) { InetAddress ip; try { ip = InetAddress.getLocalHost(); System.out.println("Current IP address : " + ip.getHostAddress()); } catch (UnknownHostException e) { e.e.printStackTrace(); } } }
Output
Current IP address : 192.168.1.22
출처 - http://www.mkyong.com/java/how-to-get-ip-address-in-java/
'Development > Java' 카테고리의 다른 글
java - json-simple parse (0) | 2014.08.19 |
---|---|
java - URLConnection, cookie, session (0) | 2014.04.17 |
java - HttpURLConnection (0) | 2014.02.07 |
java - 화폐 원 단위 콤마 표시 (2) | 2013.10.02 |
java - apache POI 소개 (0) | 2013.09.26 |