I have a file called mybundle.txt
in c:/temp
-
c:/temp/mybundle.txt
How do I load this file into a java.util.Res
For JSF Application
To get resource bundle prop files from a given file path to use them in a JSF app.
basename
property of loadBundle
tag.
For basic implementation of extended RB please see the sample at Sample Customized Resource Bundle
/* Create this class to make it base class for Loading Bundle for JSF apps */
public class Message extends ResourceBundle {
public Messages (){
File file = new File("D:\\properties\\i18n");
ClassLoader loader=null;
try {
URL[] urls = {file.toURI().toURL()};
loader = new URLClassLoader(urls);
ResourceBundle bundle = getBundle("message", FacesContext.getCurrentInstance().getViewRoot().getLocale(), loader);
setParent(bundle);
} catch (MalformedURLException ex) { }
}
.
.
.
}
Otherwise, get the bundle from getBundle method but locale from others source like Locale.getDefault()
, the new (RB)class may not require in this case.