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) {
}
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.
} catch (IOException e) {
}
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
I think i find something: http://java.sun.com/docs/books/tutorial/essential/environment/properties.html
Yes but that's only for the environmental properties. You can use the code posted above for any general properties file.
http://www.exampledepot.com/egs/java.util/Props.html