Spring
[JAVA] sever ip 얻는 방법 InetAddress.getLocalHost()
natrue
2021. 11. 28. 14:01
728x90
InetAddress.getLocalHost();
public static String getServerIp() {
InetAddress local = null;
try {
local = InetAddress.getLocalHost();
}
catch ( UnknownHostException e ) {
e.printStackTrace();
}
if( local == null ) {
return "";
}
else {
String ip = local.getHostAddress();
return ip;
}
}