如果值具有特殊字符,则Java System.getProperty返回错误的字符串

时间:2016-07-20 10:55:56

标签: java

我试图从命令行传递用户ID和密码,如下所示

mvn clean verify -Dtest.email="myemail@yahoo.com" -Dtest.password="pass$word$"

在程序中访问这些

System.out.println(System.getProperty("test.email"));
System.out.println(System.getProperty("test.password"));

返回

myemail@yahoo.com
pass

有人可以澄清为什么带有$符号的字符串会被截断并为此解决这个问题吗?

1 个答案:

答案 0 :(得分:0)

你应该引用如下的美元符号:

# data
set.seed(123)
d <- data.frame(x = runif(20, 0, 10), y = runif(20, 0, 10))
# plot the histogram,  save the parameters in n 
n <- hist(d$x, ylim = c(0, max(d$x)))
# get the x-binning, saved in n$breakes and save this in d$bins
d$bins <- .bincode(d$x,breaks = n$breaks)
# aggregate to get the y mean per bin group
a <- aggregate(d$y, list(d$bins), mean)
# add the segments
segments(x0 =  n$breaks[-length(n$breaks)], y0 = a$x, x1 = n$breaks[-1], y1 = a$x, col = "red")
# add text
text(x =  n$breaks +1, y = a$x, labels = round(a$x,2), pos = 1)

否则你将获得空字符串,因为没有为&#34; word&#34;分配值。变量