title: How to read properties file from different location in JAVA
body: <p>I have sourcehandler.java class which has the code </p>
  
  <pre><code>public class SourceHandler {
    String PrpPath = null;
    Properties prop = null;
  
   public Properties loadConfigProperties() {
  
  try {
  
      System.out.println("Propertiess " +PrpPath );
      InputStream in =new FileInputStream(new File(PrpPath ));
      prop.load(in);
  
  } catch (FileNotFoundException e) {
      e.printStackTrace();
  } catch (IOException e) {
      e.printStackTrace();
  }
  return prop;
  }
  </code></pre>
  
  <p>and main method in a different class,</p>
  
  <pre><code>    public static void main(String[] args) throws ParserConfigurationException,
                                                Exception {
      try {
  
          SourceHandler conf = new SourceHandler();
  
          conf.setProperties("C:/config.properties");
  
          Properties p = conf.loadConfigProperties();
  
          System.out.println("Done");
  
      } catch (DOMException dome) {
          // TODO: Add catch code
          dome.printStackTrace();
       }
  </code></pre>
  
  <p>Now, if i run the code , it shows null pointer exception at line ,   <code>prop.load(in);</code></p>
  
  <p>stack trace:</p>
  
  <blockquote>
    <p>java.lang.NullPointerException
        at DecryptEncryptSource.SourceHandler.loadConfigProperties(SourceHandler.java:98)
        at DecryptEncryptSource.SourceHandler.updateCofigDestn(SourceHandler.java:151)
        at DecryptEncryptSource.MainClass.main(MainClass.java:27)</p>
  </blockquote>