public static String getArgumentValue(String args[], String arg) {
        if (args == null || arg == null || arg.length() == 0 || args.length == 0) {
            return null;
        } else {
            for (int i = 0; i < args.length; i++) {
                String a = args[i];
                if (a.equalsIgnoreCase(arg)) {
                    // Case 'arg value' : Look for arg + 1;
                    if (args.length > i + 1) {
                        return args[i+1];
                    }

                } else if (a.startsWith(arg + "=")) {
                    // Case 'arg=value' : Parse the value
                    int index = a.indexOf('=') + 1;
                    return a.substring(index);
                }
            }

            return null;
        }
    }
public static String getArgumentValue ( String args [ ] , String arg ) { if ( args == null || arg == null || arg . length ( ) == 0 || args . length == 0 ) { return null ; } else { for ( int i = 0 ; i < args . length ; i ++ ) { String a = args [ i ] ; if ( a . equalsIgnoreCase ( arg ) ) { if ( args . length > i + 1 ) { return args [ i + 1 ] ; } } else if ( a . startsWith ( arg + "=" ) ) { int index = a . indexOf ( '=' ) + 1 ; return a . substring ( index ) ; } } return null ; } }
Gets the argument value.
<ul>
<li>for 'arg=value' it returns 'value'</li>
<li>for 'arg value' it returns 'value'</li>
@param args the arguments
@param arg the argument to find
@return the argument value or <code>null</code> if not found.