This week's book giveaway is in the OO, Patterns, UML and Refactoring forum.
We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line!
See this thread for details.
The moose likes EJB and other Java EE Technologies and the fly likes Reading properits file from an ejb Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Java » EJB and other Java EE Technologies
Bookmark "Reading properits file from an ejb" Watch "Reading properits file from an ejb" New topic
Author

Reading properits file from an ejb

anuja Edathu
Ranch Hand

Joined: Sep 09, 2005
Posts: 84
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

Joined: Sep 29, 2002
Posts: 1683
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.



SCJP 1.4, SCWCD 1.3, SCBCD 1.3
 
Have you checked out Aspose?
 
subject: Reading properits file from an ejb
 
jQuery in Action, 3rd edition