I am writing a simple JSF application and am trying to get a resource (database.properties file) using Class
, ClassLoader
, and URL
that is not working. url is null and I don't know why. I have done a lot of research but without success.
Code:
Class cls = Class.forName("<packagename>.SimpleDataSource");
ClassLoader cLoader = cls.getClassLoader();
URL url = cLoader.getResource(fileName); // fileName = "database.properties" w/o the double quote
FileInputStream in = new FileInputStream(url.getFile());