title: Reading a java properties file using input Stream
body: <p>I am getting null pointer exception on using InputStream along with class Loader function but on using FileInputStream it is reading the properties file correctly.</p>
  
  <p>Why I am getting this error? Given below is my code.</p>
  
  <pre><code>public String readProperties()
  {
  
      String result = "";
      Properties prop = new Properties();
      String file = "test.properties";
      //InputStream fins = getClass().getClassLoader().getResourceAsStream(file); 
      try 
      {
          prop.load(new FileInputStream(file));
          //prop.load(fins);
      } 
      catch (IOException e) {
          e.printStackTrace();
      }
  
      String nation = prop.getProperty("Nation");
      String city = prop.getProperty("City");
      String state = prop.getProperty("State");
      result = "I live in "+city+" in "+state+" in "+nation;
      return result;
  }
  </code></pre>