Link to home
Start Free TrialLog in
Avatar of komlaaa
komlaaa

asked on

Configuration Properties

Hi,
I have a Configuration Properties file that contains (variable, value) pairs. I would like to read those pairs from the file and use them to do database connection. Can someone show me a model

==== e.g Content of the file =======
password mypass
username myusername

============= in Addition ==========
i know how i can load the file content, but not how i pick a pair from it.

 // Read properties file.
    Properties properties = new Properties();
    try {
        properties.load(new FileInputStream("filename.properties"));
    } catch (IOException e) {
    }
   
 
ASKER CERTIFIED SOLUTION
Avatar of ADSLMark
ADSLMark

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Avatar of Mayank S
Mayank S
Flag of India image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
One of the best places to look for examples is Example depot:

http://www.exampledepot.com/egs/java.util/Props.html
Avatar of komlaaa
komlaaa

ASKER

Yes but that's only for the environmental properties. You can use the code posted above for any general properties file.