如何在Java中从文件资源加载资源包?
2022-08-31 20:21:10
我有一个叫入的文件mybundle.txt
c:/temp
-
c:/temp/mybundle.txt
如何将此文件加载到 ?该文件是有效的资源包。java.util.ResourceBundle
这似乎不起作用:
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 );