main.java
来自「java的经典例子」· Java 代码 · 共 38 行
JAVA
38 行
import java.text.MessageFormat;import java.util.*;class Main { static public void main(String[] args) { Locale loc = Locale.FRENCH; // Create a message format and set its locale. MessageFormat mf = new MessageFormat(""); mf.setLocale(loc); // Create a resource bundle object and load the bundle. ResourceBundle myResources = null; myResources = ResourceBundle.getBundle("MyResources", loc); // Assign the first 4 objects from the bundle to an array. Object[] arguments = { new Integer(7), new Long(System.currentTimeMillis()), myResources.getString("color"), myResources.getString("animal"), }; // Create a string buffer for the format method result. StringBuffer strbuf = new StringBuffer(""); // Get the pattern from resource bundle and apply it to mf. mf.applyPattern(myResources.getString("pattern")); // Format the objects in the arguments array to the string buffer. StringBuffer result = mf.format(arguments, strbuf, null); // Print the formatted string. System.out.println(result); }}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?