hasNext code in Java
<p>I'm having trouble opening a file. The <code>hasNext</code> seems to crashing with the following error <code>java.lang.NullPointer</code>. This is my the code that's erring out (with <code>hasNext</code>).</p>

<pre><code>import java.io.*;
import java.util.Scanner;
public class Customers{
private Scanner opener;

    public void openFile() {
        try {
            opener = new Scanner (new File ("customer.txt"));
        } catch (Exception f) {
            System.out.println("Can not read file.");
        }
    }

    public void readFile() {
        while(opener.hasNext()) {
            String a = opener.next();
            String b = opener.next();
            String c = opener.next();

            System.out.printf("%s %s %s\n", a, b, c);
        }
    }

    public void closeFile() {
        opener.close();
    }

}
</code></pre>

<p>and this is the other class:</p>

<pre><code>public class fileTest {
public static void main (String args []) {
    Customers c = new Customers();
    c.openFile();
    c.readFile();
    c.closeFile();
}
</code></pre>

<p>}</p>
