How do I load a properties file that is in the same package?

I have the following package:

com.company.ldap

In the package I have:

main.java

settings.properties

I want to load the values in the settings.properties file in code, such as:

propertiesFile ="settings.properties";

try{

properties.load(new FileInputStream(new File(propertiesFile)));

}catch (IOException e){

... error logging logic ...

}

I keep returning "The system cannot find the file specified".

How do I properly load a properties file in a class file within the same package?

Thanks,

--Todd

[858 byte] By [jtp512a] at [2007-10-3 7:43:51]
# 1

Put the file in the classpath (such as in the parent directory of com/company/ldap). Then obtain an input stream to that file like this:

InputStream stream = getClass().getResourceAsStream("/settings.properties");

Then use that stream in the properties.load method. Remember to close the stream as well.

warnerjaa at 2007-7-15 2:45:00 > top of Java-index,Java Essentials,New To Java...
# 2
Thank you. That worked great.
jtp512a at 2007-7-15 2:45:00 > top of Java-index,Java Essentials,New To Java...