public boolean getBoolean ( String key , boolean defaultValue ) { String value = get ( key ) ; // We can't use `Boolean.parseBoolean` here, as it returns false for invalid strings. if ( value == null ) { return defaultValue ; } else if ( value . equalsIgnoreCase ( "true" ) ) { return true ; } else if ( value . equalsIgnoreCase ( "false" ) ) { return false ; } else { throw new IllegalArgumentException ( value + " is not a boolean string." ) ; } }
Returns the boolean value to which the specified key is mapped or defaultValue if there is no mapping for the key . The key match is case - insensitive .