package com.xdl.dcy.java10122;
import java.text.MessageFormat;
import java.util.Locale;
import java.util.ResourceBundle;
import java.util.Scanner;
public class I18NDemo3 {
/**
* @param args
*/
public static void main(String[] args) {
Locale locale = Locale.CHINA;
ResourceBundle res = ResourceBundle.getBundle(
"com.xdl.dcy.java10122.info", locale);
while (true) {
Scanner sc = new Scanner(System.in);
System.out.println(res.getString("sys.userName"));
String name = sc.next();
System.out.println(res.getString("sys.password"));
String password = sc.next();
String welcome = MessageFormat.format(res.getString("sys.welcome"),
name);
if ("admin".equals(name) && "123".equals(password)) {
System.out.println(welcome);
System.out.println(res.getString("sys.add"));
System.out.println(res.getString("sys.del"));
System.out.println(res.getString("sys.update"));
System.out.println(res.getString("sys.query"));
break;
} else
System.out.println(res.getString("sys.err"));
}
}
}
java常用类库:国际化&处理动态文本示例
最新推荐文章于 2024-07-04 10:44:40 发布