I have one properties file, name is XYZ.properties. I want to get details from this file.
My property file location is D:\properties_file\XYZ.properties
For this i am using below code
import java.io.InputStream;
import java.util.Properties;
public class LoadProp {
    private static Properties prop = new Properties();
    public static Properties getProperties() throws Exception {
        if (prop.isEmpty()) {
            InputStream fis = LoadProp.class.getResourceAsStream("D:\\properties_file\\XYZ.properties");
            prop.load(fis);
        }
        return prop;
    }
}
public class demo extends HttpServlet {
    private static final long serialVersionUID = 1L;
    private static Properties propFile;
    public void doPost(HttpServletRequest request, HttpServletResponse response) {
        try {
            propFile = LoadProp.getProperties();
            System.out.println(propFile.getProperty(Constants.URL));
        }
        catch (ServletException e) {
            e.printStackTrace();
        } catch (IOException e) {
            e.printStackTrace();
        } catch (Exception e1) {
            e1.printStackTrace();
        }
    }
}
But when i run this on prop.load(fis) line it gives me the following error
java.lang.NullPointerException
 
     
     
    