有没有办法在java中获取命令行参数传递给程序外main函数? 我正在写一些代码,这是我无法控制的更大的应用程序的一部分,我想知道命令行参数是什么,而不修改main函数。 注意:我已经看过how to get the JVM arguments和how to get the arguments in main,但希望在我们的应用程序的其他部分获得它,而不必将它们保存在main函数中,这是我无法控制
我有一个循环来解析命令行参数。如果-d或-b参数有一个参数,一切工作正常。但是当我传递没有参数的-d或-b时,脚本进入无限循环。 # Parse command line input
while [ "$#" -gt 0 ]; do
case "$1" in
-d) DOMAIN="$2"; shift 2;;
-b) BITS="$2"; shift 2;;
#include <stdio.h>
#include <string.h>
int myatoi(char *str) {
int i, res = 0;
for (i = 0; str[i] != '\0'; ++i) {
res = res * 10 + str[i] - '0';
return res;
}
}
int ma
我想让用户提供一个4位数字作为参数的配置设置。对于特定设置A,B,C或D,每个数字将对应于True或False状态。 A B C D
0 1 0 0 # would indicate that the user wants B setting only
1 1 0 1 # would indicate that the user wants the A, B and D set