My Opera is closing 3rd of March

Li Min 李珉

Tianjin 19 Hangzhou 26 Singapore ?

Subscribe to RSS feed

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:

//This is passed in my application.
Class.getResourceAsStream ("/some/pkg/resource.properties");

//These two are not tested yet.
ClassLoader.getResourceAsStream ("some/pkg/resource.properties");
ResourceBundle.getBundle ("some.pkg.resource");