-
ResourceBundle
How do I read a boolean value from a properties file using ResourceBundle?
Code:
ResourceBundle c = ResourceBundle.getBundle("demo.OrgModify", Locale.ENGLISH);
boolean cont = Boolean.getBoolean(c.getString("Continue"));
and the properties file contains:
Continue = True
but cont is always false.
What do I need to put in the properties file to set cont=true?
(I can read string values with no problem)
-
I don't like how the documentation seems to be coupling "system property" with the Boolean.getBoolean(String name) method. You would think the String "name" is independent of system properties and required ANY String to get a boolean primitive.
Can you construct a Boolean using Boolean(String s)?
Boolean aBoolean = new Boolean(c.getString("Continue"));
boolean cont = aBoolean.booleanValue();
Also, I'm surprised that you seem to be using the class [Boolean.getBoolean(c.getString("Continue"));] while constructors are mentioned in the documentation.
-
Thanks for your reply Virt.
I've found the answer:
boolean cont = c.getString("Continue").equalsIgnoreCase("True");
-
poo poo
Your computer has developed a Virus. Please Log off and try again! :D