final int parseIPAddress(String ipAddressStr){
  int result=0;
  if (ipAddressStr == null) {
    throw new IllegalArgumentException();
  }
  try {
    String tmp=ipAddressStr;
    int offset=0;
    for (int i=0; i < 3; i++) {
      int index=tmp.indexOf('.');
      if (index != -1) {
        String numberStr=tmp.substring(0,index);
        int number=Integer.parseInt(numberStr);
        if ((number < 0) || (number > 255)) {
          throw new IllegalArgumentException("Invalid IP Address [" + ipAddressStr + "]");
        }
        result+=number << offset;
        offset+=8;
        tmp=tmp.substring(index + 1);
      }
 else {
        throw new IllegalArgumentException("Invalid IP Address [" + ipAddressStr + "]");
      }
    }
    if (tmp.length() > 0) {
      int number=Integer.parseInt(tmp);
      if ((number < 0) || (number > 255)) {
        throw new IllegalArgumentException("Invalid IP Address [" + ipAddressStr + "]");
      }
      result+=number << offset;
      ipAddress=result;
    }
 else {
      throw new IllegalArgumentException("Invalid IP Address [" + ipAddressStr + "]");
    }
  }
 catch (  NoSuchElementException ex) {
    throw new IllegalArgumentException("Invalid IP Address [" + ipAddressStr + "]",ex);
  }
catch (  NumberFormatException ex) {
    throw new IllegalArgumentException("Invalid IP Address [" + ipAddressStr + "]",ex);
  }
  return result;
}

final int parseIPAddress ( String ipAddressStr ) { int result = 0 ; if ( ipAddressStr == null ) { throw new IllegalArgumentException ( ) ; } try { String tmp = ipAddressStr ; int offset = 0 ; for ( int i = 0 ; i < 3 ; i ++ ) { int index = tmp . indexOf ( '.' ) ; if ( index != - 1 ) { String numberStr = tmp . substring ( 0 , index ) ; int number = Integer . parseInt ( numberStr ) ; if ( ( number < 0 ) || ( number > 255 ) ) { throw new IllegalArgumentException ( "Invalid IP Address [" + ipAddressStr + "]" ) ; } result += number << offset ; offset += 8 ; tmp = tmp . substring ( index + 1 ) ; } else { throw new IllegalArgumentException ( "Invalid IP Address [" + ipAddressStr + "]" ) ; } } if ( tmp . length ( ) > 0 ) { int number = Integer . parseInt ( tmp ) ; if ( ( number < 0 ) || ( number > 255 ) ) { throw new IllegalArgumentException ( "Invalid IP Address [" + ipAddressStr + "]" ) ; } result += number << offset ; ipAddress = result ; } else { throw new IllegalArgumentException ( "Invalid IP Address [" + ipAddressStr + "]" ) ; } } catch ( NoSuchElementException ex ) { throw new IllegalArgumentException ( "Invalid IP Address [" + ipAddressStr + "]" , ex ) ; } catch ( NumberFormatException ex ) { throw new IllegalArgumentException ( "Invalid IP Address [" + ipAddressStr + "]" , ex ) ; } return result ; }
convert a decimal - dotted notation representation of an ip address into an 32 bits interger value .
