How to load a resource bundle from a file resource in Java?
- by user143794
I have a file called mybundle.txt in c:/temp -
c:/temp/mybundle.txt
how do I load this file into a java.util.resource bundle?
The file is a valid resource bundle.
This does not seem to work:
java.net.URL resourceURL = null;
String path = "c:/temp/mybundle.txt";
java.io.File fl = new java.io.File(path);
try {
resourceURL = fl.toURI().toURL();
} catch (MalformedURLException e) {
}
URLClassLoader urlLoader = new URLClassLoader(new java.net.URL[]{resourceURL});
java.util.ResourceBundle bundle = java.util.ResourceBundle.getBundle( path ,
java.util.Locale.getDefault(), urlLoader );
What is the best way to do this?