private static int ipToBytes(String ip,byte[] bytes,boolean mustHave4) throws IPMatcherException {
  String[] parts=ip.split("\\.");
  if (parts.length > 4 || mustHave4 && parts.length != 4) {
    throw new IPMatcherException("Malformed IP specification " + ip);
  }
  try {
    for (int i=0; i < parts.length; i++) {
      int p=Integer.parseInt(parts[i]);
      if (p < 0 || p > 255) {
        throw new IPMatcherException("Malformed IP specification " + ip);
      }
      bytes[i]=(byte)(p < 128 ? p : p - 256);
    }
  }
 catch (  NumberFormatException nfe) {
    throw new IPMatcherException("Malformed IP specification " + ip,nfe);
  }
  return parts.length;
}

private static int ipToBytes ( String ip , byte [ ] bytes , boolean mustHave4 ) throws IPMatcherException { String [ ] parts = ip . split ( "\\." ) ; if ( parts . length > 4 || mustHave4 && parts . length != 4 ) { throw new IPMatcherException ( "Malformed IP specification " + ip ) ; } try { for ( int i = 0 ; i < parts . length ; i ++ ) { int p = Integer . parseInt ( parts [ i ] ) ; if ( p < 0 || p > 255 ) { throw new IPMatcherException ( "Malformed IP specification " + ip ) ; } bytes [ i ] = ( byte ) ( p < 128 ? p : p - 256 ) ; } } catch ( NumberFormatException nfe ) { throw new IPMatcherException ( "Malformed IP specification " + ip , nfe ) ; } return parts . length ; }
fill out a given four - byte array with the ipv4 address specified in the given string
