Revision: 26396
Initial Code
Initial URL
Initial Description
Initial Title
Initial Tags
Initial Language
at April 27, 2010 02:52 by tactoth
Initial Code
public static void main(String[] args) throws Exception { // parse arguments Map<String, String> params = new HashMap<String, String>(); for (int i = 0; i < args.length; i++) { String k = args[i], v = null; assert (k.startsWith("-")); // see if there's a value following int j = i + 1; if (j < args.length) { String _v = args[j]; if (!_v.startsWith("-")) { v = _v; i++; } } params.put(k, v); } }
Initial URL
Initial Description
input: -width 123 -height 234 -minimized -visible output map: {"-width":"123", "-height":"234", "-minimized":null, "-visible":null}
Initial Title
Parse command line in java
Initial Tags
command, line
Initial Language
Java