Java Resource Load getResourceBundleForLoc(String language, String fileName)

Here you can find the source of getResourceBundleForLoc(String language, String fileName)

Description

Gets the Resource bundle object given the language

License

Open Source License

Parameter

Parameter Description
key key for which the value needs to be fetched
fileType specifies from which property file object value has to return based on provided key
language language for which the value come form the user language

Exception

Parameter Description
IOException if any exception occurs while fetching value

Return

value value of the key

Declaration

public static Object getResourceBundleForLoc(String language, String fileName) throws IOException 

Method Source Code


//package com.java2s;
import java.io.IOException;

import java.util.Locale;

import java.util.ResourceBundle;

public class Main {
    /**/* ww w.  j  a  v a  2 s  .  c om*/
     * Gets the Resource bundle object given the language
     *
     * @param key        key for which the value needs to be fetched
     * @param fileType    specifies from which property file object
     *                 value has to return based on provided key
     * @param language   language for which the value come form the user language   
     * 
     * @return value     value of the key
     * @throws IOException if any exception occurs while fetching value
     */
    public static Object getResourceBundleForLoc(String language, String fileName) throws IOException {

        if ((language == null) || ("".equals(language))) {
            language = "en";
        }

        Locale locale = new Locale(language);
        ResourceBundle rb = ResourceBundle.getBundle(fileName, locale);
        return rb;
    }
}

Related

  1. getResourceAsString(String path)
  2. getResourceAsString(String relativePath)
  3. getResourceAsTempFile(Object context, String resourceName)
  4. getResourceBundle(String baseName)
  5. getResourceBundle(String resourceURI, Locale targetLocale)
  6. getResourceBytes(String path)
  7. getResourceByZip(final ZipInputStream zipIN, final String resourcePath)
  8. getResourceDirectory()
  9. getResourceFile(Class clazz, String path)