Name: rlT66838 Date: 06/28/99
If you read a ResourceBundle twice and the ResourceBundle's
content changed between the two getBundle() calls, ResourceBundle
does not reread the file instead it just returns a copy from its
hashtable.
For example this source-code:
import java.util. *;
import java.io. *;
class ResourceBundleTest {
private ResourceBundle bundle;
public void openResourceBundle()
{
try {
bundle = ResourceBundle.getBundle("test");
}
catch (MissingResourceException e)
{
e.printStackTrace();
}
}
public void createResourceFile(String content)
{
try {
FileWriter file = new FileWriter("test.properties");
file.write("content " + content + "\n");
file.close();
}
catch (IOException e)
{
e.printStackTrace();
}
}
public void viewResource()
{
System.out.println("Content: " + bundle.getString("content")+"\n");
}
public static void main (String args[])
{
ResourceBundleTest test = new ResourceBundleTest();
test.createResourceFile("111111111");
test.openResourceBundle();
test.viewResource();
test.createResourceFile("222222222");
test.openResourceBundle();
test.viewResource();
}
}
It should display:
Content: 111111111
Content: 222222222
but it displays:
Content: 111111111
Content: 111111111
The Resourcebundle Code should look at the filesystem if the file
has changed since the last read and use the newer one.
(Review ID: 84921)
======================================================================