`

BundleHelper

    博客分类:
  • Java
 
阅读更多
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;
		}
	}
}

 

分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics