public static int parseIntDefault(final String s,final int def){
  if (s == null) {
    return def;
  }
  int r;
  try {
    r=Integer.parseInt(s);
  }
 catch (  final NumberFormatException e) {
    r=def;
  }
  return r;
}

public static int parseIntDefault ( final String s , final int def ) { if ( s == null ) { return def ; } int r ; try { r = Integer . parseInt ( s ) ; } catch ( final NumberFormatException e ) { r = def ; } return r ; }
parses an integer safely . returning a default if nothing can be sanely parsed from it
