⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 baseresource.java

📁 打印管理程序,测试完全通过.windows开发环境.
💻 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 + -