How to access a properties file from an external location.

Hi,

I am trying to access a properties file with resource bundle,which is not present in my exsisting package.

this.getClass().getClassLoader().getResourceAsStream ("C://ResourceFile//Application.properties");

this.getClass().getResourceAsStream ("C://ResourceFile//Application.properties");

objResources = ResourceBundle.getBundle ("ResourceFile.Application");

but I am getting null in the Stream.I have to put the properties file outside of my package(i,e not in my jar file).is there any way to access it?(without using IO Stream)

[571 byte] By [Chandan_Phukana] at [2007-10-3 4:10:59]
# 1
try changing '//' to '\\'
JLuisa at 2007-7-14 22:11:22 > top of Java-index,Java Essentials,Java Programming...
# 2
Ya I tried that one also.
Chandan_Phukana at 2007-7-14 22:11:22 > top of Java-index,Java Essentials,Java Programming...
# 3
If the resource file is located in your CLASSPATH, thenobjResources = ResourceBundle.getBundle ("/ResourceFile.Application");should be fine.
Franck_Lefevrea at 2007-7-14 22:11:22 > top of Java-index,Java Essentials,Java Programming...
# 4

I have my Application.properties file in a hard coded path C:\ResourceFile(folder name)\Application.preperties.

Now I want to access this file from my program using resource bundle.

Is there any way as I am unable to get the this file from my program.Moreover I can't have my properties file in current CLASSPATH.

Chandan_Phukana at 2007-7-14 22:11:22 > top of Java-index,Java Essentials,Java Programming...
# 5

so, the standard way doesnt works?

FileInputStream fis = new FileInputStream("C:\\ResourceFile\\Application.properties");

Properties props = new Properties();

props.load(fis);

fis.close();

JLuisa at 2007-7-14 22:11:22 > top of Java-index,Java Essentials,Java Programming...
# 6
I have already tried it using IO Stream,but I am trying to get the properties file using Resource Bundle,as if I change my logic I have to make a lot of changes in my application.Anyways thanks for your suggestions.
Chandan_Phukana at 2007-7-14 22:11:22 > top of Java-index,Java Essentials,Java Programming...
# 7
ResourceBundle.getBundle() relies on a ClassLoader to locate the file. To make the loading work, there is no way other than:- putting the file inside the CLASSPATH (very easy fo fix)- writing a specific class loader to override this normal behaviour (good luck!)
Franck_Lefevrea at 2007-7-14 22:11:22 > top of Java-index,Java Essentials,Java Programming...