| Author |
Best way to open a properties file
|
sam White
Ranch Hand
Joined: Feb 18, 2011
Posts: 204
|
|
Hi,
Currently I am using the absolute path to open a properties file, shown as below:
In my PropertiesUtil constructor, I use the following code to open the file:
I am not writing a single program. The above code is written in my application package.
The problem of using this method is that, I have to pass in an absolute path of the properties file. How to use a relative path instead?
After some search, I found some example use class dot notation, eg. my.app.properties to locate a properties file.
I am not sure which way is better.
Any example and suggestion is very appreciated.
Thanks
S
|
 |
Rob Spoor
Sheriff
Joined: Oct 27, 2005
Posts: 19216
|
|
|
If you only want to read from the file you can turn it into a resource, after which you can read it through Class.getResourceAsStream or ClassLoader.getResourceAsStream.
|
SCJP 1.4 - SCJP 6 - SCWCD 5
How To Ask Questions How To Answer Questions
|
 |
 |
|
|
subject: Best way to open a properties file
|
|
|