This week's book giveaway is in the Mac OS forum.
We're giving away four copies of a choice of "Take Control of Upgrading to Yosemite" or "Take Control of Automating Your Mac" and have Joe Kissell 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


JavaRanch » Java Forums » Java » Beginning Java
Bookmark "NullPointerException at StringTokenizer" Watch "NullPointerException at StringTokenizer" New topic
Author

NullPointerException at StringTokenizer

Vijay Chandran
Ranch Hand

Joined: Jan 07, 2007
Posts: 178
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.

Thanks,
Vijay


Christophe Verré
Sheriff

Joined: Nov 24, 2005
Posts: 14688
    
  16


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: 178
Thats not what i intended.

Silly bad mistake.


Thank you very much for pointing it out.

Regards,
Vijay
 
GeeCON Prague 2014
 
subject: NullPointerException at StringTokenizer