public String getIP() {
InetAddress address = null;
try {
address = InetAddress.getLocalHost();
} catch (UnknownHostException e) {
e.printStackTrace();
}
return address.getHostAddr
JAVA获取本机IP
![](https://img-home.csdnimg.cn/images/20240711042549.png)