3、从参数列表中提取参数

 

代码
/**
* <p>
* Parses value from the argument.
* </p>
*
*
@param arg
* the argument.
*
@param key
* the switch key.
*
*
@return the parsed value.
*/
private static String parseArg(String arg, String key) {

String value
= arg.substring(key.length());

// Value cannot be empty
if (value.trim().length() == 0) {
printAndExit(
false, -1, null, "The value of switch '" + key
+ "' cannot be empty.");
}

return value;
}

 

 

4、常用变量的定义

 

代码

/**
* <p>
* Represents the switch '-config='.
* </p>
*/
private static final String SWITCH_CONFIG = "-config=";

/**
* <p>
* Represents the switch to print usage message.
* </p>
*/
private static final List<String> SWITCH_HELP = Arrays.asList(new String[]{
"-help", "-h"});
/**
* <p>
* Represents the line separator.
* </p>
*/
private static final String LINE_SEP = System.getProperty("line.separator");

 

 

 

相关文章:

  • 2021-05-28
  • 2021-11-29
  • 2021-11-29
  • 2021-06-10
  • 2022-02-28
  • 2021-11-29
  • 2022-01-01
  • 2021-09-13
猜你喜欢
  • 2021-11-19
  • 2021-09-20
  • 2022-12-23
  • 2021-09-05
  • 2021-11-29
相关资源
相似解决方案