This week's book giveaway is in the Mac OS forum. We're giving away four copies of a choice of "Take Control of Upgrading to Yosemite" or "Take Control of Automating Your Mac" and have Joe Kissell on-line! See this thread for details.
I am trying to determine the best way to retrieve a value from a property file if my key is stored in a String. The first part of the String will vary depending on input from a user (selected from a dropdown box). For example:
Property file (simple .txt file)
Book2.Title=Some Other Title
User Chooses Book1
String title = (Book1 + ".Title")
Since properties.getProperty(title) will return a null, what are my options?
Maybe I am missing something or my example wasn't that clear. Let me try again:
If I use the literal value of the String title, "Book1.Title", to access the property file it works (Some Title is returned as expected).
Book1 is actually contained in a form field, let's call it selection. I created a new String by coding String title = (selection + ".Title");
If I code System.out.println(title), "Book1.Title" is returned
What should I code to get the value of Book1.Title from the property file....properties.getProperty(???)
I hope my question is a little more clear. My apologies if it's not. I am pretty new to JAVA (only a couple months in). I have been a COBOL developer for 16+ years and I am finding this transition to be a little difficult. The above seems like it should be so easy, but I can't get it to work.
If the String value "Book1.Title" is contained in the variable title that's the exact same thing as calling getProperty("Book1.Title").
Joined: Mar 27, 2010
Okay, nevermind. I went back to my original code and modified the keys in my property file (had a combinaTION of lower case & caps). I guess that's what happens when you look at something for too long. Should have stepped away. Now I can rest easy for the remainder of the weekend. Thanks for taking time to respond.