| Author |
Loading Properties file
|
morteza av
Greenhorn
Joined: May 10, 2011
Posts: 3
|
|
I write tow method for my class to obtain correct file path in FileInputStream class to loading Properties file:
and use:
Its work in netbeans IDE correctly, but when I compile my class the .properties file miss in dist folder. It don’t work even I paste .properties file inside my app folder.
Can you help me?
|
 |
Chinna Eranna
Ranch Hand
Joined: Dec 08, 2009
Posts: 174
|
|
Where does setting.properties file exist ?
inside some package(of class directory) ?
|
- Chinna
|
 |
Wouter Oet
Saloon Keeper
Joined: Oct 25, 2008
Posts: 2700
|
|
|
Small hint for the method getClassName(): look at the method Class.getSimpleName()
|
"Any fool can write code that a computer can understand. Good programmers write code that humans can understand." --- Martin Fowler
Please correct my English.
|
 |
morteza av
Greenhorn
Joined: May 10, 2011
Posts: 3
|
|
Chinna Eranna wrote:Where does setting.properties file exist ?
inside some package(of class directory) ?
setting.properties exist in class directory.
|
 |
Chinna Eranna
Ranch Hand
Joined: Dec 08, 2009
Posts: 174
|
|
I believe you don't need to do all the stuff you are doing.
Just use as shown
Remember the argument to getResourceAsStream(), should include the packages path if the properties file is under any java package.
For ex, if it is under com/xyz/setting.properties, then the argument should be "/com/xyz/setting.properties".
|
 |
Vijitha Kumara
Bartender
Joined: Mar 24, 2008
Posts: 3670
|
|
|
And welcome to the Ranch, Morteza Av!
|
SCJP 5 | SCWCD 5
[How to ask questions] [Twitter]
|
 |
morteza av
Greenhorn
Joined: May 10, 2011
Posts: 3
|
|
|
Thanks all friends.
|
 |
 |
|
|
subject: Loading Properties file
|
|
|