code: private static void validateIPAddress(String ipAddress) {
          try {
              @SuppressWarnings("unused")
              Inet4Address address = (Inet4Address) Inet4Address.getByName(ipAddress);
          }
          catch (Exception ex) {
              throw new IllegalArgumentException(String.format(SR.INVALID_IP_ADDRESS, ipAddress), ex);
          }
      }
docs: Validate that the IP address is IPv4.
  
  @param ipAddress
  the IP address to validate