/ Published in: Java
input: -width 123 -height 234 -minimized -visible
output map: {"-width":"123", "-height":"234", "-minimized":null, "-visible":null}
output map: {"-width":"123", "-height":"234", "-minimized":null, "-visible":null}
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
{ // parse arguments for (int i = 0; i < args.length; i++) { assert (k.startsWith("-")); // see if there's a value following int j = i + 1; if (j < args.length) { if (!_v.startsWith("-")) { v = _v; i++; } } params.put(k, v); } }