This week's book giveaway is in the Jobs Discussion forum.
We're giving away four copies of Java Interview Guide and have Anthony DePalma on-line!
See this thread for details.
The moose likes Beginning Java and the fly likes NullPointerException at StringTokenizer Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Java Interview Guide this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "NullPointerException at StringTokenizer" Watch "NullPointerException at StringTokenizer" New topic

NullPointerException at StringTokenizer

Vijay Chandran
Ranch Hand

Joined: Jan 07, 2007
Posts: 186

Dear friends,

The following code gives me a problem.

I am passing two command-line arguments. First arg is an input file name with full path. Second arg is an output folder with full path.
Example first arg: C:\Program Files\MyFolder\Test.txt
Example second arg: C:\Program Files\MyFolder\Output

When i run the code using

java "C:\Program Files\MyFolder\Test.txt" "C:\Program Files\MyFolder\Output"

the above code gives me a NullPointerException at [// 1].

I am checking while(in.readLine() != null) when the end of file is reached. But still its by-passing the condition and executes the while loop.

Following is the stack trace:

Kindly provide your valuable help.


Christophe Verré

Joined: Nov 24, 2005
Posts: 14688

You are reading two lines here. Is this what you intend to do ?

[My Blog]
All roads lead to JavaRanch
Vijay Chandran
Ranch Hand

Joined: Jan 07, 2007
Posts: 186

Thats not what i intended.

Silly bad mistake.

Thank you very much for pointing it out.

I agree. Here's the link:
subject: NullPointerException at StringTokenizer
It's not a secret anymore!