Im using the below code to read a properties file in my servlet. I would like to get clarified about the getClass.getClassLoader().getResourceAsStream(...)
line.
From my understanding, getClassLoader()
will get the class loader associated with the Servlet class that I have defined. But how that is associated with propFileName
?
Properties prop = new Properties();
String propFileName = "config.properties";
InputStream inputStream = getClass().getClassLoader().getResourceAsStream(propFileName);
prop.load(inputStream);
String user = prop.getProperty("GOOGLE_CLIENT_ID");
String id = prop.getProperty("GOOGLE_REDIRECT_URL");