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.
My question is more related to Web Applications. I want to store some properties in a property file. To read this file I need to provide the path to the file holding the properties.
My question is:
1) what are options in order to provide this path. I can myself think of two ways a) Hard code the path in my class b) Give the path as a system property The second option has the disadvantage that if I provide my app as a war it cannot be deployed as is. I do not want to use first option for obvious reasons.
2) My second question I want to be able to read the properties and load them at startup of the application. Where should I put my code to do this? Also in case I want to read these properties per user session where should I put my code to read the properties.
java.io.tmpdir this system property point to dir that does not exit.It store ur property file path in system temp directory.So, there is no need to hard code it just make instance and access the file path.
just look at this API
Bhupinder SCJP1.4 Preparing SCWCD
SCJP1.4<br />SCWCD1.5<br />"Nothing is impossible"
Look for the getResourceAsStream method, it will let you place properties files in the same packages as your classes are. It will help you also with the war stuff because you will deploy your properties file in the same archive as your other java classes.
She will remember your heart when men are fairy tales in books written by rabbits.<br /> As long as there is duct tape... there is also hope.