How to put string in bundle
I have in my code this piece of code
ResourceBundle resbundle=ResourceBundle.getBundle("test", Locale.getDefault());
resbundle.getString("compileItem");
How to put 开发者_开发百科another string in this bundle ?
If you are trying to do this programatically then the interface does not provide any methods for modifying a bundle, so unless you find an implementation that has extensions to allow such, you cant.
If you just want to add a value to the bundle edit the text file test.properties (or the locale specific version if necessary) and add the line:
compileItem=foo
ResourceBundle objects are read-only.
They are designed for looking up locale-specific resources such as text translations, images, icons, ...
They are not meant to be written. If you want something similar to a ResourceBundle but writeable, then maybe a Properties object is what you're after, or even a simple Map.
That depends on which actual implementation class you end up using. Typically that's PropertyResourceBundle, which means you have to add the string to the underlying property file since the class is read-only. But if you implement your own subclass of ResourceBundle, it could support adding entries at runtime.
 
         加载中,请稍侯......
 加载中,请稍侯......
      
精彩评论