BundleHelper

import java.util.Locale;
import java.util.ResourceBundle;

public class BundleHelper {
	public static String GetStringFromBundle(String BundleName, String key, String defaultString)
	{
		String result = defaultString;
		if (util.isEmpty(key)|| util.isEmpty(BundleName))
		{
			return result;
		}
		else
		{
			try
			{
				ResourceBundle oBundle = ResourceBundle.getBundle(BundleName);
				result = oBundle.getString(key);
			}
			catch(Exception ex)
			{
				ex.printStackTrace();
			}
			return result;
		}
	}
	
	public static String GetStringFromBundle(String BaseName, Locale locale, String key, String defaultString)
	{
		String result = defaultString;
		if (util.isEmpty(key) || util.isEmpty(BaseName))
		{
			return result;
		}
		else
		{
			try
			{
				ResourceBundle oBundle = ResourceBundle.getBundle(BaseName, locale);
				result = oBundle.getString(key);
			}
			catch(Exception ex)
			{
				ex.printStackTrace();
			}
			return result;
		}
	}
}

 

你可能感兴趣的:(Bundle)