I won’t say much nonsense, I will just post the code to you. The specific code is as follows:
public String getLocalHostName() {String hostName;try {InetAddress addr = InetAddress.getLocalHost();hostName = addr.getHostName();} catch (Exception ex) {hostName = "";}return hostName;}public String[] getAllLocalHostIP() {String[] ret = null;try {String hostName = getLocalHostName();if (hostName.length() > 0) {InetAddress[] addrs = InetAddress.getAllByName(hostName);if (addrs.length > 0) {ret = new String[addrs.length];for (int i = 0; i < addrs.length; i++) {ret[i] = addrs[i].getHostAddress();}}}} catch (Exception ex) {ret = null;}return ret;}The above code is the relevant code for obtaining local IPs of multiple network cards introduced by the editor. If you have any questions, please leave me a message. I will communicate with you in time and learn and make progress together. At the same time, I would like to thank you very much for your support for the Wulin Network website!