解决国际化问题!比如:要将一个英文版的java软件汉化,只修改一两个相关类(或几个文本文件)就可以了,而不必更改整个系统,和全部重新编译。docs中的原话:
    Resource bundles contain locale-specific objects. When your program needs a locale-specific resource, a String for example, your program can load it from the resource bundle that is appropriate for the current user's locale. In this way, you can write program code that is largely independent of the user's locale isolating most, if not all, of the locale-specific information in resource bundles. This allows you to write programs that can: 
  a. be easily localized, or translated, into different languages .
  b. handle multiple locales at once .
  c. be easily modified later to support even more locales .

解决方案 »

  1.   

    这个类是与外部资源交互的,可以读 *.properties 文件的数据。例如:ResourceBundle rb = ResourceBundle.getBundle("test");
    这句 把rb这个对象绑定到 test.properties 文件,可以从文件中读取数据。
    然后用 rb.getString("XXX") 得到test文件中定义好的数据。
      

  2.   

    可以解决国际化问题.
    ResourceBundle bundle = ResourceBundle.getBundle("资源文件");
    例如:
    fileMenu.setText(bundle.getString("FILEMENU_LABEL"));
    得到菜单的名称.需要修改的时候在资源文件中修改就可以了.
      

  3.   

    可以在不同地区,显式不同语言文本
    test_en.properties
    name=Filetest_fr.properties
    name=Fichiertest_zh.properties
    name=\u6587\u4ef6
    ResourceBundle b=ResourceBundle.getBundle("test");
    System.out.println(b.getString("name"));在中国是文件,在英美是File,法国Fichier
      

  4.   

    to 香水梨:
          也就是说属性文件中的数据是从程序外给定的是么?自己编写的程序本身不能设定其中的数据是这样的么?谢谢!这个类是与外部资源交互的,可以读 *.properties 文件的数据。例如:ResourceBundle rb = ResourceBundle.getBundle("test");
    这句 把rb这个对象绑定到 test.properties 文件,可以从文件中读取数据。
    然后用 rb.getString("XXX") 得到test文件中定义好的数据。
      

  5.   

    主要是为了多语言版本,有时甚至可以用它来建立菜单等,例子在jdk\demo\jfc\notepad