Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Reading properits file from an ejb

 
anuja Edathu
Ranch Hand
Posts: 84
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hai all,
I am trying to read a properties file say xx.properties from an ejb ReadBean.
i packaged the properties file in to the jar. But when i tried to execute, an exception is being caught (exceptionjava.io.FileNotFoundException:xx.properties.


Properties properties = new Properties();
try {
properties.load(new FileInputStream("xx.properties"));
System.out.println(properties.getProperty("asd"));
} catch (IOException e) {
System.out.println("exception"+ e);
}
Can any one help me out! If i have to change the path of properties file where i have to put it?

Thanks & Regards
Anuja K.
 
Roger Chung-Wee
Ranch Hand
Posts: 1683
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I normally recommend creating a ResourceBundle from a properties file. However, if you wish to use the Properties class, try the following code which calls the class loader to find the file and return an input stream.

 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic