简体   繁体   中英

Boolean value in properties file

As we know that in properties file every value is treated as 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. The problem is that I can not modify the java source executing this condition XYZ :

if (XYZ) {
  //do something
}

Currently this condition always returns the String true instead of a boolean with the value false .

Can I do something in properties file to make it a boolean?

从属性文件中获取值后,您可以使用:if(Boolean.valueOf(XYZ)){...}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM