public static Map<String,String> simpleCommandLineParser(String[] args){
  Map<String,String> map=new HashMap<String,String>();
  for (int i=0; i <= args.length; i++) {
    String key=(i > 0 ? args[i - 1] : null);
    String value=(i < args.length ? args[i] : null);
    if (key == null || key.startsWith("-")) {
      if (value != null && value.startsWith("-"))       value=null;
      if (key != null || value != null)       map.put(key,value);
    }
  }
  return map;
}

public static Map < String , String > simpleCommandLineParser ( String [ ] args ) { Map < String , String > map = new HashMap < String , String > ( ) ; for ( int i = 0 ; i <= args . length ; i ++ ) { String key = ( i > 0 ? args [ i - 1 ] : null ) ; String value = ( i < args . length ? args [ i ] : null ) ; if ( key == null || key . startsWith ( "-" ) ) { if ( value != null && value . startsWith ( "-" ) ) value = null ; if ( key != null || value != null ) map . put ( key , value ) ; } } return map ; }
simple method which turns an array of command line arguments into a map , where each token starting with a ' - ' is a key and the following non ' - ' initial token , if there is one , is the value . for example , ' - size 5 - verbose ' will produce keys ( - size , 5 ) and ( - verbose , null ) .
