Merge branch 'dev_robotaxi-d-app-module_2130_221116_2.13.0' into dev_robotaxi-d-app-module_2110_220915_2.11.0_cmdb
This commit is contained in:
@@ -23,6 +23,7 @@ import java.io.InputStreamReader;
|
||||
import java.io.LineNumberReader;
|
||||
import java.io.UnsupportedEncodingException;
|
||||
import java.lang.reflect.Field;
|
||||
import java.net.Inet4Address;
|
||||
import java.net.InetAddress;
|
||||
import java.net.NetworkInterface;
|
||||
import java.net.SocketException;
|
||||
@@ -397,8 +398,27 @@ public class CommonUtils {
|
||||
|
||||
}
|
||||
|
||||
public static String getIpAddressString() {
|
||||
try {
|
||||
for (Enumeration<NetworkInterface> enNetI = NetworkInterface
|
||||
.getNetworkInterfaces(); enNetI.hasMoreElements(); ) {
|
||||
NetworkInterface netI = enNetI.nextElement();
|
||||
for (Enumeration<InetAddress> enumIpAddr = netI
|
||||
.getInetAddresses(); enumIpAddr.hasMoreElements(); ) {
|
||||
InetAddress inetAddress = enumIpAddr.nextElement();
|
||||
if (inetAddress instanceof Inet4Address && !inetAddress.isLoopbackAddress()) {
|
||||
return inetAddress.getHostAddress();
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (SocketException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return "127.0.0.1";
|
||||
}
|
||||
|
||||
// 获取本地IP函数
|
||||
private static String getLocalIPAddress() {
|
||||
public static String getLocalIPAddress() {
|
||||
try {
|
||||
Enumeration<NetworkInterface> mEnumeration = NetworkInterface.getNetworkInterfaces();
|
||||
if (mEnumeration != null) {
|
||||
|
||||
Reference in New Issue
Block a user