aspose file tools*
The moose likes Beginning Java and the fly likes NullPointerException Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "NullPointerException" Watch "NullPointerException" New topic
Author

NullPointerException

Brian LaRue
Ranch Hand

Joined: Feb 01, 2006
Posts: 45
after creating my class, at run-time, I'm getting a NullPointerException. I'm wondering why this is occuring. JVM doesn't like my array for some reason.
Here's my code so far:



What am I doing wrong? Any help is greatly appreciated.

Brian
Ernest Friedman-Hill
author and iconoclast
Marshal

Joined: Jul 08, 2003
Posts: 24187
    
  34

Hi Brian,

The stack trace should tell you exactly what line of what file the NullPOinterException occurs on; can you tell show us exactly that line of code?


[Jess in Action][AskingGoodQuestions]
Brian LaRue
Ranch Hand

Joined: Feb 01, 2006
Posts: 45


Thanks for offering your help...
Christophe Verré
Sheriff

Joined: Nov 24, 2005
Posts: 14688
    
  16

remove the semicolon :
while ((line = bfr.readLine()) != null); {

Be careful 1) You should check the size of the array returned by the split method.
Be careful 2) You are declaring a array of 4 elements, while trying access 5

In fact, you don't even need to declare a new instance.
Just do :

and check the size of the array with parts.length
[ February 16, 2006: Message edited by: Satou kurinosuke ]

[My Blog]
All roads lead to JavaRanch
Brian LaRue
Ranch Hand

Joined: Feb 01, 2006
Posts: 45
Awe man, I'm an idiot. I should have guessed that it was something obvious! Doh! That did it, thanks for the insight!
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: NullPointerException