[英]Boolean value in properties file
As we know that in properties file every value is treated as String. 我们知道在属性文件中,每个值都被视为String。 For example I've a property in my file:
例如,我在我的文件中有一个属性:
XYZ=false
I want to use the String false above as a boolean value in a condition. 我想在条件中使用String false作为布尔值。 The problem is that I can not modify the java source executing this condition XYZ :
问题是我无法修改执行此条件XYZ的java源:
if (XYZ) {
//do something
}
Currently this condition always returns the String true instead of a boolean with the value false . 目前,此条件始终返回String true而不是值为false的布尔值。
Can I do something in properties file to make it a boolean? 我可以在属性文件中做一些事情来使它成为布尔值吗?
从属性文件中获取值后,您可以使用:if(Boolean.valueOf(XYZ)){...}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.