| Author |
StringTokenizer / NullPointerException problem
|
Tyler Jordan
Ranch Hand
Joined: Nov 17, 2003
Posts: 70
|
|
I have been getting a NullPointerException during this specific section in my application. I assume that the StringTokenizer is grabbing a null value which is causing the problem, but it is my understanding that the hasMoreTokens() method should eliminate that problem. The input file that I use is a .csv file. This is the error.
|
 |
Joanne Neal
Rancher
Joined: Aug 05, 2005
Posts: 3011
|
|
You don't call hasMoreTokens until you have made at least one call to nextToken. But what I think your problem really is, is that you don't check if 'line' is null before passing it to StringTokenizer.
|
Joanne
|
 |
Tyler Jordan
Ranch Hand
Joined: Nov 17, 2003
Posts: 70
|
|
|
What I'll do is add a string like EOF on the end of my classcodes file and use that as a delimiter for the end of the file. This is a little cludgy, but it will at least narrow the focus.
|
 |
Joanne Neal
Rancher
Joined: Aug 05, 2005
Posts: 3011
|
|
line will be set to null when you reach the end of the file so why don't you use that to end your while loop Try
|
 |
 |
|
|
subject: StringTokenizer / NullPointerException problem
|
|
|