Win a copy of Think Java: How to Think Like a Computer Scientist this week in the Java in General forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

how to read properties file from different package

 
Ami Choc
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 299
Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi AMi,

This should work
Properties props = new Properties();
props.load(getClass().getClassLoader().getResourceAsStream("test2/test2.properties"));
System.out.println(":::::"+keyfromtheprofile);
Regards
Jatan
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic