title: How to write junit test cases for IOException
body: <p>I want to check the IOException class in JUNIT testing. Here is my code:</p>
  
  <pre><code>public void loadProperties(String path) throws IOException {
    InputStream in = this.getClass().getResourceAsStream(path);
    Properties properties = new Properties();
    properties.load(in);
    this.foo = properties.getProperty("foo");
    this.foo1 = properties.getProperty("foo1");
  }
  </code></pre>
  
  <p>when I try to give false properties file path it gives NullPointerException. I want to get IOException and Junit test for it. Thank you very much for your help.</p>