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 Android Security Essentials Live Lessons this week in the Android 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
 
 
subject: how to read properties file from different package
 
Similar Threads
Adding to property files...
File Not Found Exception While Reading Properties File
reading from property file
location of a property file
Error reading properties file