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.
The moose likes Java in General and the fly likes Property Files Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Java » Java in General
Bookmark "Property Files" Watch "Property Files" New topic
Author

Property Files

Dale DeMott
Ranch Hand

Joined: Nov 02, 2000
Posts: 515
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)
Michael Ernest
High Plains Drifter
Sheriff

Joined: Oct 25, 2000
Posts: 7292

Have you tried it without the .properties suffix?
------------------
Michael Ernest, co-author of: The Complete Java 2 Certification Study Guide


Make visible what, without you, might perhaps never have been seen.
- Robert Bresson
Dale DeMott
Ranch Hand

Joined: Nov 02, 2000
Posts: 515
Actually I have. That is what this line does...
System.out.println(testUtil.loadPropertiesFile("afsllc", "test"));
The file I'm looking for is afsllc.properties
Jim Yingst
Wanderer
Sheriff

Joined: Jan 30, 2000
Posts: 18671
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.


"I'm not back." - Bill Harding, Twister
David Weitzman
Ranch Hand

Joined: Jul 27, 2001
Posts: 1365
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.
Dale DeMott
Ranch Hand

Joined: Nov 02, 2000
Posts: 515
Please explain more. What do you mean more directly.
------------------
By failing to prepare, you are preparing to fail.
Benjamin Franklin (1706 - 1790)
David Weitzman
Ranch Hand

Joined: Jul 27, 2001
Posts: 1365
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).]
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Property Files