• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

NullPointerException at StringTokenizer

 
Vijay Chandran
Ranch Hand
Posts: 186
Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 14691
16
Eclipse IDE Ubuntu VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

You are reading two lines here. Is this what you intend to do ?
 
Vijay Chandran
Ranch Hand
Posts: 186
Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thats not what i intended.

Silly bad mistake.


Thank you very much for pointing it out.

Regards,
Vijay
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic