Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Finding a properties file 1

Status
Not open for further replies.

Wiszh

Programmer
Aug 3, 2000
134
0
0
US
Hi,

How can I have the JVM find a properties file located in a subdirectory of the package structure (for example have com.app.Prog find com/app/resource/prog.properties).

Thanx

Wiszh
 
Just let me know whether I have understood your question correctly.
You have a class Prog in the package com.app.
You want to access a property file Prog.properties from the above mentioned class which is located in com/app/resource/prog.properties and
your problem is in identifying the path to the property file...Is that it .

 
when you open your file, you need the full path or relative path from where u are at present to the properties..just like opening any other file
 
I don't really understand your question.
Look forward to hearing more from you.
 
To load a properties file from the classpath do this:

Properties props = new Properties();
InputStream in = getClass().getResourceAsStream("prog.properties");
props.load(in);

Regards,

Charles
 
Hi Wiszh,

try this:

getResourceBundle("com.app.resource.prog")

Regards,

anjas
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top