Friday, March 31, 2006
Resources Accessing in Java
If you want to access the resource files in an unique form in Java, please do NOT use FileInputStream because it can not work porperly in JAR file.
Instead of FileInputStream, please try the functions below:
ClassLoader.getResourceAsStream ("some/pkg/resource.properties");
Class.getResourceAsStream ("/some/pkg/resource.properties"); //This is passed in my application. The others are not tested yet.
ResourceBundle.getBundle ("some.pkg.resource");
Instead of FileInputStream, please try the functions below:
ClassLoader.getResourceAsStream ("some/pkg/resource.properties");
Class.getResourceAsStream ("/some/pkg/resource.properties"); //This is passed in my application. The others are not tested yet.
ResourceBundle.getBundle ("some.pkg.resource");