code: public static int parseNumericAddress(String ipaddr) {
      Matcher m = IP_ADDRESS_PATTERN.matcher(ipaddr);
      int ipInt = 0;
      if (m.find()) {
        for (int i = 1;i < 5;i++) 
          try {
            int ipVal = Integer.valueOf(m.group(i)).intValue();
            if ( ipVal < 0 || ipVal > 255) {
              return 0;
            }
            //  Add to the integer address
            ipInt = (ipInt << 8) + ipVal;
          }
          catch (NumberFormatException ex) {
            return 0;
          }
      }
      //  Return the integer address
      return ipInt;
    }
docs: Check if the specified address is a valid numeric TCP/IP address and return as an integer value
  
  @param ipaddr String
  @return int