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");



Comments: Post a Comment



<< Home

This page is powered by Blogger. Isn't yours?