bundles.java
来自「一个基于eclipse插件开发的聊天程序」· Java 代码 · 共 62 行
JAVA
62 行
package talkServer.business;import java.text.MessageFormat;import java.util.MissingResourceException;import java.util.ResourceBundle;public class Bundles { // bundles in the application private static ResourceBundle maps_resourceBundle = ResourceBundle.getBundle("maps"); public static ResourceBundle getMaps_resourceBundle() { return maps_resourceBundle; } public static void setMaps_resourceBundle(ResourceBundle maps_resourceBundle) { Bundles.maps_resourceBundle = maps_resourceBundle; } private Bundles() { } /** * Gets a string from the resource bundle. * We don't want to crash because of a missing String. * Returns the key if not found. */ public static String getResourceString(String key,ResourceBundle resourceBundle) { try { return resourceBundle.getString(key); } catch (MissingResourceException e) { return key; } catch (NullPointerException e) { return "!" + key + "!"; } }// public static String[] getResourceStringArray(String key, ResourceBundle resourceBundle) {// try {// return resourceBundle.getStringArray(key);// } catch (MissingResourceException e) {// return null;// } catch (NullPointerException e) {// return null;// } // } /** * Gets a string from the resource bundle and binds it * with the given arguments. If the key is not found, * return the key. */ public static String getResourceString(String key, Object[] args, ResourceBundle resourceBundle) { try { return MessageFormat.format(getResourceString(key,resourceBundle), args); } catch (MissingResourceException e) { return key; } catch (NullPointerException e) { return "!" + key + "!"; } }}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?