views:

424

answers:

5

http://pastebin.com/m5fa7685e

It seems to fail when getting f3.. Output is:

not ready

File is null
Exception in thread "main" java.lang.NullPointerException
    at BuabFile.parseBUAB(BuabFile.java:93)
    at AddressBook.createBrowseForm(AddressBook.java:232)
    at AddressBook.(AddressBook.java:51)
    at Main.main(Main.java:4)"

But not before then - no file not found errors or anything...

+1  A: 

My guess would be that the parseBUAB() method receives a "null" argument. Which means that it could be that it is the AddressBook class is responsible for the error.

jhominal
A: 

In your call to parseBUAB, buabfile (of type ArrayList<String>) is null. Your problem lies in the creation of that ArrayList, which is in code that you haven't shown. Look to where you're creating that object, likely in the AddressBook class.

Michael Petrotta
A: 

From all I can see, you just call parseBUAB(..) with a null value. I can't see the call to that method so you have to check the rest of your code.

For your 'not ready' output, which is created because your BufferedReader f3 is 'not ready', the API says

True if the next read() is guaranteed not to block for input, false otherwise.

Maybe you just call it too fast and the file is not loaded yet. Play with Thread.sleep() before calling ready() on the stream. Maybe a some-milliseconds blocking is just normal for File I/O.

And third - if f3 is the BufferedReader you want to keep, you have to assign it to the member file in the readFile() method. But now that's all I found ;)

Andreas_D
A: 

It looks like you forgot to assign a value to BuabFile.file static field. You may want to add this to the end of your readFile() method:

BuabFile.file = f3;

I am guessing your AddressBook.createBrowseForm method looks something like this:

String filename = ...;
BuabFile buab = new BuabFile(filename);
buab.readFile();
ArrayList<String> buabLines = buab.returnFile(); // Returns null because readFile() never assigned a value to BuabFile.file
ArrayList<Buab> buabList = buab.parseBUAB(buabLines);
Adam Paynter
A: 

I'm confused further but have found an answer sort of - I'm using windows 7 and have tried it on a windows xp computer and the code compiles fine and reads in the file (other errors you lot have noted are to be changed anyway through development - this was just one stick in the way...).

I'm wondering if there is some Windows 7 error with eclipse and opening/reading files...

Josh Anderson