public static Integer toInteger(String str){
  try {
    return Integer.valueOf(str);
  }
 catch (  Exception ex) {
    return null;
  }
}

public static Integer toInteger ( String str ) { try { return Integer . valueOf ( str ) ; } catch ( Exception ex ) { return null ; } }
casts string to integer or returns null if value is not integer
