|
马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。
您需要 登录 才可以下载或查看,没有帐号?立即注册
x
java也能做一些底层语言开发做的事情(难度很高,不是java顶尖高手是做不来的),目次布局:
一切的文件都在包demo下.
MlLogin.java
packagedemo;
importjava.util.ListResourceBundle;
publicclassMlLoginextendsListResourceBundle
{
publicMlLogin()
{
}
staticfinaljava.lang.Object[][]contents={
{"lblUserName","lblUserName"},
{"lblPassword","lblUserName"},
{"caseName","lblUserName"}
};
publicjava.lang.Object[][]getContents(){
returncontents;
}
}
ApplicationResource_zh_TW.properties
error.requiredfield=Thefieldisrequiredtosave
label.phone=u96fbu8a71
label.name=u540du5b57
MlLogin_zh_TW.java
packagedemo;
importjava.util.ListResourceBundle;
publicclassMlLogin_zh_TWextendsListResourceBundle
{
publicMlLogin_zh_TW()
{
}
staticfinaljava.lang.Object[][]contents={
{"lblUserName",""},
{"lblPassword","密a"},
{"caseName","登进"}
};
publicjava.lang.Object[][]getContents(){
returncontents;
}
}
FormatExample.java
packagedemo;
importjava.util.ResourceBundle;
importjava.util.Locale;
importjava.text.MessageFormat;
/**
*
*@authorlimohao
*/
publicclassFormatExample{
/**CreatesanewinstanceofFormatExample*/
publicFormatExample(){
}
publicstaticvoidmain(String[]args){
Stringss="demo.ApplicationResource";
ResourceBundlebundle=ResourceBundle.getBundle(ss);
StringrequiredFieldMessage=bundle.getString("error.requiredfield");
String[]messageArgs=newString[1];
messageArgs[0]=bundle.getString("label.name");
StringformatNameMessage=MessageFormat.format(requiredFieldMessage,messageArgs);
System.out.println(formatNameMessage);
messageArgs[0]=bundle.getString("label.phone");
StringformatPhoneMessage=MessageFormat.format(requiredFieldMessage,messageArgs);
System.out.println(formatPhoneMessage);
try{
//Classtest=Class.forName("demo.mlLogin");
//Stringcname=test.getName();
Stringcname="demo.MlLogin";
bundle=bundle.getBundle(cname);
Stringtemp=bundle.getString("lblUserName");
System.out.println(temp);
}catch(Exceptione){
e.printStackTrace();
}
}
}
Note:假如是在简体情况下测试可将zh_TW改成zn_CN
你说是sun公司对她研究的透还是微软?针对自己工具开发的.net性能上肯定会站上风的。 |
|