resourcebundle.java

来自「Mofire的JAR压缩包」· Java 代码 · 共 72 行

JAVA
72
字号
// Decompiled by Jad v1.5.8e2. Copyright 2001 Pavel Kouznetsov.
// Jad home page: http://kpdus.tripod.com/jad.html
// Decompiler options: packimports(3) fieldsfirst ansi space 
// Source File Name:   ResourceBundle.java

package com.modofo.mofire;

import java.io.*;
import java.util.Hashtable;

public class ResourceBundle
{

	private Hashtable map;
	private static ResourceBundle instance = null;

	private ResourceBundle(String fileName)
		throws IOException
	{
		map = new Hashtable();
		StringBuffer completeFileName = new StringBuffer();
		completeFileName.append("/");
		completeFileName.append(fileName);
		completeFileName.append("_");
		completeFileName.append(System.getProperty("microedition.locale"));
		completeFileName.append(".properties");
		InputStream in = getClass().getResourceAsStream(completeFileName.toString());
		if (in == null)
		{
			String x = completeFileName.toString();
			completeFileName = new StringBuffer(x.substring(0, x.indexOf(System.getProperty("microedition.locale"))));
			completeFileName.append("en-US.properties");
			in = getClass().getResourceAsStream(completeFileName.toString());
		}
		DataInputStream din = new DataInputStream(in);
		StringBuffer line = new StringBuffer();
		byte c;
		while ((c = (byte)in.read()) != -1) 
			if (c != 10 && c != 13)
			{
				line.append(new String(new byte[] {
					c
				}));
			} else
			{
				String aux = line.toString();
				String key = aux.substring(0, aux.indexOf("=")).trim();
				String message = aux.substring(aux.indexOf("=") + 1, aux.length());
				line = new StringBuffer();
				map.put(key, message);
			}
	}

	public static final void init(String fileName)
		throws IOException
	{
		if (instance == null)
			instance = new ResourceBundle(fileName);
	}

	public static final ResourceBundle getInstance()
	{
		return instance;
	}

	public String getString(String key)
	{
		return (String)map.get(key);
	}

}

⌨️ 快捷键说明

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