Apache Commons CLI:替代已弃用的 OptionBuilder? [英] Apache Commons CLI: replacement for deprecated OptionBuilder?
本文介绍了Apache Commons CLI:替代已弃用的 OptionBuilder?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
IntelliJ 显示在来自 http://commons.apache.org/的示例代码中不推荐使用 OptionBuilder正确/commons-cli/usage.html.
IntelliJ shows that OptionBuilder is deprecated in this example code from http://commons.apache.org/proper/commons-cli/usage.html.
我应该用什么来替代?
import org.apache.commons.cli.*;
Options options = new Options();
options.addOption(OptionBuilder.withLongOpt( "block-size" )
.withDescription( "use SIZE-byte blocks" )
.hasArg()
.withArgName("SIZE")
.create());
推荐答案
来自 http://commons.apache.org/proper/commons-cli/javadocs/api-release/index.html
已弃用.从 1.3 开始,改用 Option.builder(String)
Deprecated. since 1.3, use Option.builder(String) instead
这是替代品:
Options options = new Options();
Option option = Option.builder("a")
.longOpt( "block-size" )
.desc( "use SIZE-byte blocks" )
.hasArg()
.argName( "SIZE" )
.build();
options.addOption( option );
这篇关于Apache Commons CLI:替代已弃用的 OptionBuilder?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文