0

Java。 I need to verify whether the IPv6 network segment is legal。Who has had the same problem? Thank you。

com.google.common.net.InetAddresses。Only IPv6 format can be verified

/**
   * Returns {@code true} if the supplied string is a valid IP string literal, {@code false}
   * otherwise.
   *
   * @param ipString {@code String} to evaluated as an IP string literal
   * @return {@code true} if the argument is a valid IP string literal
   */
  public static boolean isInetAddress(String ipString) {
    return ipStringToBytes(ipString) != null;
  }

0 Answers0