title: Reading Properties file in Java
body: <p>I have the following code trying to read a properties file:</p>
  
  <pre><code>Properties prop = new Properties();
  ClassLoader loader = Thread.currentThread().getContextClassLoader();           
  InputStream stream = loader.getResourceAsStream("myProp.properties");
  prop.load(stream);
  </code></pre>
  
  <p>I get an exception at the last line. Specifically:</p>
  
  <pre><code>Exception in thread "main" java.lang.NullPointerException
  at java.util.Properties$LineReader.readLine(Properties.java:418)
  at java.util.Properties.load0(Properties.java:337)
  at java.util.Properties.load(Properties.java:325)
  at Assignment1.BaseStation.readPropertyFile(BaseStation.java:46)
  at Assignment1.BaseStation.main(BaseStation.java:87)
  </code></pre>
  
  <p>thanks,
  Nikos</p>