我正在使用Apache CLI来解析命令行参数。我的一个参数是一个带字符串MyApp -f "search for this string"
我想当我做cmdLine.getOptionValue("f")
它会返回:search for this string
然而,它只返回search
我应该怎么做以确保检索整个字符串,显然只是用双引号将其包装似乎不起作用。
我在ubuntu上。
答案 0 :(得分:3)
我认为传递带有额外单引号的字符串应该有效:
MyApp -f "'search for this string'"
答案 1 :(得分:0)
在Windows上,参数必须用双引号引起来。在Unix上,您可以使用简单的引号,双引号或使用反斜杠转义空格。
答案 2 :(得分:0)
MyApp -f 'search for this string'
在UNIX上用单引号(')括起字符串对我来说很有效。 Apache CLI JIRA网站上的comment可能会有所帮助。