java中是否有任何函数的行为类似于c的getopt [英] is there any function in java which behaves like getopt from c

查看:41
本文介绍了java中是否有任何函数的行为类似于c的getopt的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好,我正在命令行应用程序上工作,该应用程序可以接受

之类的命令行参数.

  app -port 8888-文件名d:\ xyz \ xyz.pdf -dest d:\ pqr 

我正在寻找可以返回一对选项及其对应值的函数,例如c中的getopt.

解决方案

那里有许多用于Java的命令行解析器库.

picocli 是最新的(截至2019年末)具有很多功能的命令行解析器./p>

一些较老的受欢迎的是 commons-cli (相当古老), args4j JCommander

Hello I am working on command line application which can accepts command line argument like

app -port 8888 -filename d:\xyz\xyz.pdf -dest d:\pqr

I am looking for function which can return me pair of option and it corresponding value like getopt in c.

解决方案

There are quite a few command line parser libraries for Java out there.

A recent (as of late 2019) command line parser with a lot of momentum and features is picocli.

Some older, popular ones are commons-cli (quite old), args4j and JCommander.

这篇关于java中是否有任何函数的行为类似于c的getopt的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆