2
ここには次のような取引があります。埋められないとタイムスタンプ接頭辞を作成するフラグ "-pre"が必要です。塗りつぶされている場合は、指定さApache Commons CLIオプションと位置指定の引数
Option prefixOption = OptionBuilder.create(O_PREFIX);
prefixOption.setLongOpt(O_PREFIX_LONG);
prefixOption.setArgName("prefix");
prefixOption.setDescription("Put a prefix (default is timestamp) to output directory.");
prefixOption.setType(String.class);
prefixOption.setOptionalArg(true);
以降..
System.out.println(commandLine.hasOption(O_PREFIX));
System.out.println(commandLine.getOptionValue(O_PREFIX));
処刑:
\> mon_execution -pre
true
null
\> mon_execution -pre Hahaha
true
null
と私は引数の使用を強制する場合
prefixOption.setArgs(1); (in first snipet)
を事前コマンドラインは次のパラメータを取ります-preのパラメータとして指定し、tを破棄する彼は解析する。