testmybundle.java

来自「程序练习中包括书中实例程序代码和练习中要用到的代码,是压缩文件」· Java 代码 · 共 34 行

JAVA
34
字号
package examples.i18n;

import java.util.ResourceBundle;
import java.util.Enumeration;
import java.util.Locale;

public class TestMyBundle {
   /** Test method for the class
     * @param args not used
     */
   public static void main( String[] args ) {
      ResourceBundle rb;
      String bundleName = "examples.i18n.MyBundle";
      rb = ResourceBundle.getBundle( bundleName,
                                     Locale.CANADA );
      print( "CANADA Locale:", rb );
   }
   /** Print the contents of a resource file
     * @param label the label given to the output
     * @param rb the ResourceBundle object to print
     */
   public static void print( String label,
                             ResourceBundle rb ) {
      System.out.println( label );
      Enumeration e = rb.getKeys();
      String key;
      while( e.hasMoreElements() ) {
         key = (String) e.nextElement();
         System.out.println( "\t" + key + " = " 
                             + rb.getObject( key ) );
      }
   }
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?