What is the best option for reading Java property files?
I have an application which uses a servlet to read an intialization parameter from web.xml for the location of a property file. The serlvet then creates an instance of a class which stores the location of the file for other programs to read as required. This class has appropriate get and set methods.
But my question concerns access to the properties: should the physical property file be read by each program as at runtime or should the properties开发者_JAVA百科 be stored in memory instead?
The properties are not currently altered at runtime but this could change? I've seen various alternative approaches but am not sure which is best.
Thanks
Mr Morgan
If the properties file is not large, then storing it in memory may be more efficient than reading it from disk everytime. You may want to consider Apache Commons Configuration. It supports automatic reloading.
Do you want to server values from .properties file? First load the properties from the file and cache them.And server it from the cache when required. Have a file watch dog that monitors the file say every x sec and reload the properties from file when the file is modified.
加载中,请稍侯......
精彩评论