code: public static String getLocalNetWorkIp() {
          if (localIp != null) {
              return localIp;
          }
          try {
              Enumeration<NetworkInterface> netInterfaces = NetworkInterface.getNetworkInterfaces();
              InetAddress ip = null;
              while (netInterfaces.hasMoreElements()) {// 遍历所有的网卡
                  NetworkInterface ni = (NetworkInterface) netInterfaces.nextElement();
                  if (ni.isLoopback() || ni.isVirtual()) {// 如果是回环和虚拟网络地址的话继续
                      continue;
                  }
                  Enumeration<InetAddress> addresss = ni.getInetAddresses();
                  while (addresss.hasMoreElements()) {
                      InetAddress address = addresss.nextElement();
                      if (address instanceof Inet4Address) {// 这里暂时只获取ipv4地址
                          ip = address;
                          break;
                      }
                  }
                  if (ip != null) {
                      break;
                  }
              }
              if (ip != null) {
                  localIp = ip.getHostAddress();
              } else {
                  localIp = "127.0.0.1";
              }
          } catch (Exception e) {
              localIp = "127.0.0.1";
          }
          return localIp;
      }
docs: 获取本机的网络IP