I have a property file placed in the root of the web project in Java. I am using Struts 2. My code is unable to read properties file. Where should I keep my properties file?
Keep your myPropertyFile.properties file in src folder (after build project you will find it in WEB-INF/classes) and access them using this code:
Properties prop = new Properties();
ClassLoader classLoader = Thread.currentThread().getContextClassLoader();
prop.load(classLoader.getResourceAsStream("/myPropertyFile.properties"));