mirror of https://gitee.com/stylefeng/roses
【rule】增加一个工具类获取本机hostname
parent
50c0557585
commit
0d5cf04f33
|
@ -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 "未知";
|
||||
}
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in New Issue