This week's book giveaway is in the OCAJP forum. We're giving away four copies of OCA Java SE 8 Programmer I Study Guide 1Z0-808 and have Jeanne Boyarsky & Scott Selikoff on-line! See this thread for details.
Hi All, I have a basic doubt about the resource bundle object. I wanted to know if the creation of ResoureBundle object loads the entire property file or will it just create the pointer to file and every request to a key will do an I/O operation? I think that the file gets loaded into memory(Please correct if I am wrong). In that case I feel that use of too many property files reduces the performance of the application. I hope my concern is clear. Waiting for all of your response. Thanks, Mrutyunjay [ June 20, 2002: Message edited by: Mrutyunjay Hanchinal ]
I had the same doubt last year when I was working on Internationalisation of a CRM product. Considering issues like frequent IO/file-reads (so not many small files) and efficient memory management (so no ONE single large file), I ended up suggesting with module level .properties files. (That was not the best option, I should say now.) That is one resource bundle per module of the product. That also helped us to manage module wise licenses efficiently. Also another issue with a property file serving more than one class is, it becomes increasingly tedious for developers and will end up with duplicate keys! Anyway, let the discussion continue... Ashok.
Hi, Thanks Ashok for your reply. It appears from the reply of Ashok that the key value pairs in property file get loaded on to memory and hence it is not an I/O or File read operation instead it is burden on the memory. Is this understanding correct? Please suggest Thanks, Mrutyunjay
If you call ResourceBundle.getBundle("foo") several times, it caches what bundle it gave you and you get the same thing every time. So there is little extra cost for calling getBundle several times to retrieve the same bundle (you don't need to cache it yourself). When ResourceBundle loads a properties file, the entire file is loaded when it is created using Properties.load(). Forums like this are a good place to get answers, but don't forget that the JDK comes with java source (in src.jar). So you can always check up on us by looking at the source yourself