title: Reading a text from a file in java with ArrayList
body: <p>I want to write a method for reading a data from a file in java using ArrayList instead of static String[] array. This is what I wrote so far: </p>
  
  <pre><code>public static ArrayList&lt;String&gt; loadText(String file) {
      ArrayList&lt;String&gt; ret = null;
      BufferedReader in = null;
      String line = null;
          try {
              in = new BufferedReader(new FileReader(file));
              while((line = in.readLine()) != null) {
                  ret.add(line);
              }
          } catch (Exception e){
              e.printStackTrace();
          } finally {
              if(in != null) {
                  try {
                      in.close();
                  } catch (Exception e){
                      e.printStackTrace();
                  }
              }
          }
  
          return ret;
      }
  </code></pre>
  
  <p>And this is how i called this method in my Test class:</p>
  
  <pre><code>import java.util.ArrayList;
  
  public class Test {
  
      /**
       * @param args
       */
      public static void main(String[] args) {
          // TODO Auto-generated method stub
          ArrayList&lt;String&gt; text = Files.loadText("podaci.txt");
  
          System.out.println(text);
      }
  }
  </code></pre>
  
  <p>There is a problem with: </p>
  
  <p>ret.add(line);</p>
  
  <p>I'm getting NullPointerException, and i can't figure out why...</p>