Get the tools you need to learn Java skills fast!
Video tutorials, eBooks, hands-on lab exercises, sample code.
Get started
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 The Software Craftsman this week in the Agile 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: 297

hi AMi,

This should work
Properties props = new Properties();
props.load(getClass().getClassLoader().getResourceAsStream("test2/test2.properties"));
System.out.println(":::::"+keyfromtheprofile);
Regards
Jatan
 
Have you tried LearnNowOnline? http://www.learnnowonline.com/
 
subject: how to read properties file from different package