public int strDistance(char[] a,char[] b) throws SAXException {
  if (a.length == b.length) {
    int distance=0;
    for (int i=0; i < a.length; i++) {
      int tDist=Math.abs(Character.getNumericValue(a[i]) - Character.getNumericValue(b[i]));
      distance+=tDist;
    }
    return distance;
  }
 else {
    throw new SAXException("Unable to compute SAX distance, string lengths are not equal");
  }
}

public int strDistance ( char [ ] a , char [ ] b ) throws SAXException { if ( a . length == b . length ) { int distance = 0 ; for ( int i = 0 ; i < a . length ; i ++ ) { int tDist = Math . abs ( Character . getNumericValue ( a [ i ] ) - Character . getNumericValue ( b [ i ] ) ) ; distance += tDist ; } return distance ; } else { throw new SAXException ( "Unable to compute SAX distance, string lengths are not equal" ) ; } }
compute the distance between the two strings , this function use the numbers associated with ascii codes , i . e . distance between a and b would be 1 .
