private String toHex(int i){
  String result;
  result=Integer.toHexString(i);
  if (result.length() < 2) {
    result="0" + result;
  }
  return result;
}

private String toHex ( int i ) { String result ; result = Integer . toHexString ( i ) ; if ( result . length ( ) < 2 ) { result = "0" + result ; } return result ; }
returns a two hexadecimal representation of i , if shorter than 2 chars then an additional " 0 " is put in front
