Results 1 to 4 of 4

Thread: ResourceBundle

  1. #1

    Thread Starter
    Frenzied Member Mark Sreeves's Avatar
    Join Date
    Nov 1999
    Location
    UK
    Posts
    1,845

    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)
    Mark
    -------------------

  2. #2
    VirtuallyVB
    Guest
    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.

  3. #3

    Thread Starter
    Frenzied Member Mark Sreeves's Avatar
    Join Date
    Nov 1999
    Location
    UK
    Posts
    1,845
    Thanks for your reply Virt.

    I've found the answer:

    boolean cont = c.getString("Continue").equalsIgnoreCase("True");
    Mark
    -------------------

  4. #4

    Exclamation poo poo

    Your computer has developed a Virus. Please Log off and try again!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width