Here you can find the source of findResourceBundle(String aBundleName, Locale locale)
Parameter | Description |
---|---|
aBundleName | the name of the bundle (usually it's FQN classname). |
locale | the locale. |
public static ResourceBundle findResourceBundle(String aBundleName, Locale locale)
//package com.java2s; import java.util.*; public class Main { private static final Collection misses = new HashSet(); /**//from w ww . ja v a2 s .co m * @GuardedBy #misses */ private static ClassLoader delegatedClassLoader; /** * Finds the given resorce bundle by it's name. * <p/> * Will use <code>Thread.currentThread().getContextClassLoader()</code> as the classloader. * If {@link #delegatedClassLoader} is defined and the bundle cannot be found the current classloader it will delegate to that. * * @param aBundleName the name of the bundle (usually it's FQN classname). * @param locale the locale. * @return the bundle, <tt>null</tt> if not found. */ public static ResourceBundle findResourceBundle(String aBundleName, Locale locale) { synchronized (misses) { try { if (!misses.contains(aBundleName)) { return ResourceBundle.getBundle(aBundleName, locale, Thread.currentThread().getContextClassLoader()); } } catch (MissingResourceException ex) { if (delegatedClassLoader != null) { try { return ResourceBundle.getBundle(aBundleName, locale, delegatedClassLoader); } catch (MissingResourceException e) { misses.add(aBundleName); } } else { misses.add(aBundleName); } } } return null; } }