File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
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
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
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
 
subject: how to read properties file from different package