static Properties argumentsToProperties ( String [ ] args ) { Properties props = new Properties ( ) ; for ( String arg : args ) { if ( ! arg . startsWith ( "-D" ) || ! arg . contains ( "=" ) ) { throw new IllegalArgumentException ( String . format ( "Command-line argument must start with -D, for example -Dsonar.jdbc.username=sonar. Got: %s" , arg ) ) ; } String key = StringUtils . substringBefore ( arg , "=" ) . substring ( 2 ) ; String value = StringUtils . substringAfter ( arg , "=" ) ; props . setProperty ( key , value ) ; } return props ; }
Convert strings - Dkey = value to properties