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

📄 resourcebundle.java

📁 针对moto sdk的经典源代码
💻 JAVA
字号:
/**
 * ResourceBundle.java
 *
 * Oct. 15, 2004 
 *
 * (c) Copyright. 2004. Motorola , Inc. ALL RIGHTS RESERVED.
 *  This notice does not imply publication. 
 *
 */ 
import java.util.*;
import java.io.*;

/**
 * Simplified j2me edition of ResourceBoundle.
 */

public class ResourceBundle {

	static Hashtable loopup = new Hashtable();
	
	private String resourceFile;
	private Hashtable props;

	private ResourceBundle (String rc) {
		this.resourceFile = rc;
	}

	/**
	 * Guess the resource bundle file from bundle name and locale.
	 */
	static private String getRCFile (String bundleName, String locale) {
        String resName = "/" + bundleName.replace('.', '/') + "_" + locale +".properties";
		return resName;
	}
	
	static public ResourceBundle getResourceBundle (String bundleName, String locale) {
		String resourceFile = getRCFile(bundleName, locale);

		Object o = loopup.get(resourceFile);
		
		if (o != null)
			return (ResourceBundle) o;

		ResourceBundle bundle = new ResourceBundle (resourceFile);
		loopup.put (resourceFile, bundle);

		return bundle;
	}


	boolean parsed = false;
	public String getString (String key) {

		// Parse when the first time getString() called
		if (!parsed) {
			InputStream is = getClass().getResourceAsStream (resourceFile);
			
			if (is == null) {
                                return "isnull";
                               // return key;
			} else {
				ResourceParser parser= new ResourceParser(is);
				try {
				props = parser.parse ();
				} catch (IOException ioe) {
                                        //return key;
                                        return ioe.getMessage();
				}
			}
			parsed = true;
		}

		String value = (String)props.get(key);

		if (value == null) {
                        return "keynull";
                        //return key;
		}

		return value;
	}
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -