This week's book giveaway is in the OCPJP forum. We're giving away four copies of OCA/OCP Java SE 7 Programmer I & II Study Guide and have Kathy Sierra & Bert Bates on-line! See this thread for details.
So when working with property files, where do I need to put the property files for the system to find them. And what do I need to name them. Currently I have the properties file named AFSLLC.properties and when I look for it I put in the following code... (it can't find it right now)
Not sure why its not finding it. Can anyone shed some light on this to why this can't be found. I'm calling the method with
it can't find 'afsllc.properties'. Thanks in advance! -Dale
------------------ By failing to prepare, you are preparing to fail. Benjamin Franklin (1706 - 1790)
By failing to prepare, you are preparing to fail.<br />Benjamin Franklin (1706 - 1790)
Whatever file name you give the properties file, that's the name you need to pass to the Properties load() method - including the suffix. I don't know what your loadPropertiesFile() method does, but it needs to append the suffix ".properties" suffix to "afsllc" in order to function as you seem to desire. Additionally you may have a problem with not knowing what directory your program is running from - I suggest you put in a call to <pre> System.out.println(new File("afsllc.properties").getAbsolutePath()); </pre> just before you call the Properties load() method, to see what exactly it's looking for.
Are you sure you want to be using a resoure bundle? Do you plan to have many translations of you program? It might be easier and more predictable to load the properties file more directly.
Joined: Nov 02, 2000
Please explain more. What do you mean more directly. ------------------ By failing to prepare, you are preparing to fail. Benjamin Franklin (1706 - 1790)
Joined: Jul 27, 2001
ResourceBundles' claim to faim is that they allow you to specify different properties depending on the Locale of the executing virtual machine. You can create global.properties (if property is not found anywhere else) and global_en.properties (specifically for english speakers) and global_en_US.properties (overrides some english/global stuff for united statesians) and global_fr.properties (for french people), etc. If you don't need this, then you might as well just call Properties.load(FileInputStream). [This message has been edited by David Garland (edited August 21, 2001).]