Im trying to read a file from a fileserver by setting up an ftp connection, where the path is passed as argument to the method. I have this following line to read the file from the given path, but it is throwing a null pointer exception.
Maybe it'd be easier if you told us what was actually null.
Joined: Oct 28, 2008
I could not test some of your suggestions as i ran into an other problem. I'm using SFTP to read files from the fileserver (not ftp. My apologies) and the license for using it expired. Now I have to replace sftp with ftp. I would like to know how do I replace sftp with ftp. The code to establish sftp connection is shown below.
Well, if that particular line is throwing the NPE (meaning that line is at the top of the stack trace, no other lines above it) then the variable "ftp" must be null at that point. Nothing else on that line could possibly throw an NPE. If you don't believe me, then try replacing it with:
You probably only need the first line - but this is an example of how you can debug a NullPointerException by figuring out exactly which thing is really null, as David suggests.