M tryng 使用 apache commons cli ,我的用例是带有一些选项的可变数量的参数。
说
-p str1 str2;
有可能
-p str1 str2 str3 .. strn
另一个是
-m str1
-h
和
cmdline.getOptionValues("p");
它只获取最后一个字符串。如何获取特定选项的所有值?
编辑:
if(cmdline.hasOption("p")){
String[] argsList = cmdline.getOptionValues(p);
String strLine = Arrays.toString(argsList);
argsList = strLine.split(",");
}
我做对了吗?字符串是否会包含我想要的确切数据或smthng 意外的空格或其他任何内容?