public static int getInt ( Properties config , String key , int defaultValue ) { String val = config . getProperty ( key ) ; if ( val == null ) { return defaultValue ; } else { try { return Integer . parseInt ( val ) ; } catch ( NumberFormatException nfe ) { throw new IllegalArgumentException ( "Value for configuration key='" + key + "' is not set correctly. " + "Entered value='" + val + "'. Default value='" + defaultValue + "'" ) ; } } }
Get integer from properties . This method throws an exception if the integer is not valid .