Here you can find the source of parseArg(String[] args)
public static Map<String, String> parseArg(String[] args)
//package com.java2s; import java.util.HashMap; import java.util.Map; public class Main { public static Map<String, String> parseArg(String[] args) { Map<String, String> map = new HashMap<String, String>(); if (args == null || args.length == 0) return map; String lastKey = null;//from w w w . ja va 2s. c o m for (int i = 0; i < args.length; i++) { if (args[i] == null || args[i].equals("")) continue; if (args[i].startsWith("-")) { lastKey = args[i].substring(1); } else { if (lastKey != null) { map.put(lastKey, args[i]); lastKey = null; } else { map.put(args[i], null); } } } if (lastKey != null) map.put(lastKey, null); return map; } }