-
Notifications
You must be signed in to change notification settings - Fork 0
Open
Description
/**
* 获取本机的IP地址
* @return 本机的IP地址(可能包含多个)
*/
private static List<String> getLocalIp() {
List<String> listIp = new ArrayList<String>();
Enumeration<NetworkInterface> n = null;
try {
n = NetworkInterface.getNetworkInterfaces();
} catch (SocketException e) {
e.printStackTrace();
}
while (n.hasMoreElements()) {
NetworkInterface e = n.nextElement();
Enumeration<InetAddress> ee = e.getInetAddresses();
while (ee.hasMoreElements()) {
InetAddress addr = ee.nextElement();
listIp.add(addr.getHostAddress());
}
}
return listIp;
} Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels