eg:
class.skeleton= public class {0} extends Trade '{\n\
\n\
\tpublic int init() throws Exception\n\
\t{\n\
\t\treturn 0;\n\
\t}\n\
\n\
}\n'
测试代码:
public class MessageFormatDemo {
/**
* @param args
*/
public static void main(String[] args) {
String result = null;
ResourceBundle rb = ResourceBundle.getBundle("plugin");
String pattern = rb.getString("class.skeleton");
System.out.println("pattern: " + pattern);
result = MessageFormat.format(pattern, "MyTrade");//经此Format,{0}内容会被替换为"MyTrade""
System.out.println(result);
}
}
我们可以将所有不确定的东西放到配置文件中去,比如放到*.properties文件中。
键命名规则:
以对话框或视图或编辑器名称作为前缀,以"_"分隔,
eg:
FilteredItemsSelectionDialog_storeError=Storing the dialog failed
FilteredItemsSelectionDialog_restoreError=Restoring the dialog failed
FilteredItemsSelectionDialog_taskProgressMessage={0} ({1}%)
FilteredItemsSelectionDialog_subtaskProgressMessage={0}: {1}
在Eclipse平台中,可以通过ResourceBundle或NLS两种方式从*.properties中获取值