1 import java.text.MessageFormat;
2 import java.util.MissingResourceException;
3 import java.util.ResourceBundle;
4
5
6
7
8 class MessageUtil {
9 private static final String RESOURCE_BUNDLE = "messages";
10
11 private static ResourceBundle fgResourceBundle
12 = ResourceBundle.getBundle(RESOURCE_BUNDLE);
13
14 private MessageUtil() {
15
16 }
17
18
19
20
21
22
23
24
25
26 public static String format(String key, Object[] args) {
27 return MessageFormat.format(getString(key), args);
28 }
29
30
31
32
33
34
35
36
37
38 public static String getString(String key) {
39 try {
40 return this.fgResourceBundle.getString(key);
41 } catch (MissingResourceException e) {
42 return "!" + key + "!";
43 }
44 }
45
46 public static ResourceBundle getResourceBundle() {
47 return this.fgResourceBundle;
48 }
49 }
CategoryJava
ZbmonWiki: MessageUtil.java (2005-11-07 14:30:29에 zbmon가(이) 마지막으로 수정)