title: java.lang.NullPointerException: Cannot get property 'text' on null object
body: <p>I am trying to read a file. The file is in the same folder as the class file. Below is my code:</p>
  
  <pre><code>class TestClass {
  
   static void readFile(String fileName) {
      // input stream
      def text =  TestClass.class.getClassLoader().getResourceAsStream(fileName).text;
      def lines = text.split('\n')
      print(lines);
    }
  
    public static void main(args) {
    readFile('abc.txt');
    }
  }
  </code></pre>
  
  <p>However I get java.lang.NullPointerException: Cannot get property 'text' on null object.</p>