Apache Commons Command Line Interface 1.3.1 尝试从这里使用 它对于必需的参数工作正常,但似乎删除了任何可选参数。有人能发现我下面的代码有问题吗?
import org.apache.commons.cli.CommandLine;
import org.apache.commons.cli.CommandLineParser;
import org.apache.commons.cli.DefaultParser;
import org.apache.commons.cli.Option;
import org.apache.commons.cli.Options;
import org.apache.commons.cli.ParseException;
public class TestCommandLine {
public static void main(String[] args) {
// ***** test with command line arguments -R myfirstarg -O mysecondarg *****
// ***** the second arg is not being captured *****
System.out.println("Number of Arguments : " + args.length);
String commandline = "";
for (String arg : args) {
commandline = commandline + (arg + " ");
}
commandline.trim(); …Run Code Online (Sandbox Code Playgroud)