private static boolean getSystemProp ( final String key , final boolean defaultValue ) { String val = System . getProperty ( key ) ; if ( val == null ) val = System . getenv ( key ) ; if ( val == null ) { return defaultValue ; } else if ( val . isEmpty ( ) ) { return true ; } else { switch ( val . toLowerCase ( Locale . ROOT ) ) { case "t" : case "true" : case "1" : return true ; case "f" : case "false" : case "0" : return false ; default : throw new IllegalArgumentException ( "Invalid value, expected true/false: " + val ) ; } } }
an error rather than return false . The default can also be specified .