📄 baseresource.java
字号:
package jp.co.ntl;
import java.io.IOException;
import java.io.InputStream;
import java.util.Locale;
import java.util.MissingResourceException;
import java.util.PropertyResourceBundle;
import java.util.ResourceBundle;
public class BaseResource {
private ResourceBundle bundle = null;
private Locale locale;
private ClassLoader clsLoader;
private String moduleName;
public BaseResource(ClassLoader clsLoader, String moduleName) {
this.clsLoader = clsLoader;
this.moduleName = moduleName;
}
public void load(Locale l) {
locale = l;
String fileName = moduleName + "_" + locale.getLanguage();
if (locale.getCountry().length() > 0) {
fileName += "_" + locale.getCountry();
}
fileName += ".properties";
InputStream is = clsLoader.getResourceAsStream(fileName);
try {
bundle = new PropertyResourceBundle(is);
is.close();
} catch (IOException e) {
fileName = moduleName + "_en.properties";
is = clsLoader.getResourceAsStream(fileName);
try {
bundle = new PropertyResourceBundle(is);
is.close();
} catch (IOException e1) {
}
}
}
public String getString(String key) {
String s = null;
try {
// 2006.10.10丂夋柺偺僼儕僢僇懳墳 lium add begin
if (bundle != null)
// 2006.10.10丂夋柺偺僼儕僢僇懳墳 lium add end
s = bundle.getString(key);
} catch (MissingResourceException e) {}
if (s == null) {
s = "";
}
return s;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -