传递给Java main()的命令行参数中的引号 [英] Quotes in command line arguments passed to Java main()
问题描述
我使用以下命令行运行Java程序(在NetBeans 6.8项目属性中,)
I run a Java program with the following command line ( in NetBeans 6.8 project properties)
toto has:"tutu titi"
args是2个字符串组成的数组
args is an array of 2 Strings
toto
has:tutu titi
我希望(确实有两个参数,第二个) args [1]
是
I want (two arguments indeed, the second) args[1]
to be
has:"tutu titi"
我应该怎么做?
我已经尝试过在Netbeans项目属性中的参数"行中使用反斜杠转义引号,但是我得到了args [1]
I have already tried escaping the quotes with backslash from "Arguments" line in Netbeans propject properties, but I get args[1]
has:\tutu titi\
推荐答案
我在NetBeans中遇到了类似的问题,并找到了解决方案:
I had a similar problem in NetBeans and found the solution:
在private.properties中编辑/添加属性"application.args"到此:
Edit/Add the property "application.args" in your private.properties to this:
application.args='has:""tutu titi""'
用单引号标记您的参数",用两个双引号定义一个双引号".
Single quotes to mark your "argument" and two double quotes to define one "double quotes".
这篇关于传递给Java main()的命令行参数中的引号的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!