wood burning stoves 2.0*
The moose likes Java in General and the fly likes how to read properties file from different package Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "how to read properties file from different package" Watch "how to read properties file from different package" New topic
Author

how to read properties file from different package

Ami Choc
Greenhorn

Joined: Aug 06, 2012
Posts: 8
I have properties file which is in different package from where i want to access

below code does not works..can any one please help


InputStream in = getClass().getResourceAsStream("/Test/bin/test.properties");

FileInputStream fis = new FileInputStream("/Test/bin/test.properties");

props.load(fis);

Thanks in Advance !!
jatan bhavsar
Ranch Hand

Joined: Jul 23, 2008
Posts: 296

hi AMi,

This should work
Properties props = new Properties();
props.load(getClass().getClassLoader().getResourceAsStream("test2/test2.properties"));
System.out.println(":::::"+keyfromtheprofile);
Regards
Jatan
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: how to read properties file from different package
 
Similar Threads
reading from property file
File Not Found Exception While Reading Properties File
Adding to property files...
Error reading properties file
location of a property file