【rule】增加一个工具类获取本机hostname

pull/3/head
fengshuonan 2021-01-10 19:06:45 +08:00
parent 50c0557585
commit 0d5cf04f33
1 changed files with 28 additions and 0 deletions

View File

@ -0,0 +1,28 @@
package cn.stylefeng.roses.kernel.rule.util;
import java.net.InetAddress;
import java.net.UnknownHostException;
/**
* IP
*
* @author fengshuonan
* @date 2021/1/10 14:25
*/
public class IpInfoUtils {
/**
* hostname
*
* @author fengshuonan
* @date 2021/1/10 18:40
*/
public static String getHostName() {
try {
return InetAddress.getLocalHost().getHostName();
} catch (UnknownHostException ignored) {
return "未知";
}
}
}