Posted By:
Jonathan_Downey
Posted On:
Tuesday, April 8, 2003 02:48 AM
Please don't ask the same question twice at the same time. It discourages people from bothering with the Forums if they're full of duplicate questions.
Here's a code snippet:
public Properties loadProps(String fileName) throws Exception {
Properties props = null;
FileInputStream istr = null;
try{
istr = new FileInputStream( fileName );
props = new Properties();
props.load( istr );
} finally {
if(istr!=null)
istr.close();
}
return props;
}
You can use
props.getProperty( keyName )
to read a value. Your Properties file has values like
#This is a sample Properties File
username=jdowney
password=somepassword
folder=c:\test
Note the \ when specifying folder names (Windows, obviously).
Oh, and "Read the documentation" is a pretty lame answer. Don't answer if that's your response. There's a shed-load of documentation in the API. At least mention the class that the person asking the question needs.
Jonathan.