基础,每天记录一点点。ResourceBundle使用

xiaoxiao2026-03-26  0

I18NSample.java import java.util.*;public class I18NSample { static public void main(String[] args) { String language; String country; if (args.length != 2) { language = new String("en"); country = new String("US"); } else { language = new String(args[0]); country = new String(args[1]); } Locale currentLocale; ResourceBundle messages; currentLocale = new Locale(language, country); messages = ResourceBundle.getBundle("MessagesBundle",currentLocale); System.out.println(messages.getString("greetings")); System.out.println(messages.getString("inquiry")); System.out.println(messages.getString("farewell")); }} MessagesBundle_en_US.properties greetings = Hello.farewell = Goodbye.inquiry = How are you? MessagesBundle_de_DE.properties greetings = Hallo.farewell = Tsch.inquiry = Wie geht's?
转载请注明原文地址: https://www.6miu.com/read-5046264.html

最新回复(0)