带有空格的Apache CLI选项值

hba*_*hba 10 java apache ubuntu command-line command-line-interface

我正在使用Apache CLI来解析命令行参数.我的一个参数是一个带字符串的过滤器MyApp -f "search for this string"

我想当我这样做cmdLine.getOptionValue("f")会回来:search for this string

但它只是回归 search

我该怎么做才能确保检索整个字符串,显然只是用双引号将其包装起来似乎不起作用.

我在ubuntu上.

cab*_*bad 2

我认为传递带有额外单引号的字符串应该有效:

MyApp -f "'search for this string'"
Run Code Online (Sandbox Code Playgroud)